
obj/user/testpipe:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 e7 02 00 00       	call   800318 <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>
	...

00800034 <umain>:

char *msg = "Now is the time for all good men to come to the aid of their party.";

void
umain(void)
{
  800034:	55                   	push   %ebp
  800035:	89 e5                	mov    %esp,%ebp
  800037:	56                   	push   %esi
  800038:	53                   	push   %ebx
  800039:	83 c4 80             	add    $0xffffff80,%esp
	char buf[100];
	int i, pid, p[2];

	argv0 = "pipereadeof";
  80003c:	c7 05 7c 70 80 00 c0 	movl   $0x802fc0,0x80707c
  800043:	2f 80 00 

	if ((i = pipe(p)) < 0)
  800046:	8d 45 8c             	lea    -0x74(%ebp),%eax
  800049:	89 04 24             	mov    %eax,(%esp)
  80004c:	e8 a8 27 00 00       	call   8027f9 <pipe>
  800051:	89 c6                	mov    %eax,%esi
  800053:	85 c0                	test   %eax,%eax
  800055:	79 20                	jns    800077 <umain+0x43>
		panic("pipe: %e", i);
  800057:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80005b:	c7 44 24 08 cc 2f 80 	movl   $0x802fcc,0x8(%esp)
  800062:	00 
  800063:	c7 44 24 04 0e 00 00 	movl   $0xe,0x4(%esp)
  80006a:	00 
  80006b:	c7 04 24 d5 2f 80 00 	movl   $0x802fd5,(%esp)
  800072:	e8 0d 03 00 00       	call   800384 <_panic>

	if ((pid = fork()) < 0)
  800077:	e8 46 13 00 00       	call   8013c2 <fork>
  80007c:	89 c3                	mov    %eax,%ebx
  80007e:	85 c0                	test   %eax,%eax
  800080:	79 20                	jns    8000a2 <umain+0x6e>
		panic("fork: %e", i);
  800082:	89 74 24 0c          	mov    %esi,0xc(%esp)
  800086:	c7 44 24 08 e5 2f 80 	movl   $0x802fe5,0x8(%esp)
  80008d:	00 
  80008e:	c7 44 24 04 11 00 00 	movl   $0x11,0x4(%esp)
  800095:	00 
  800096:	c7 04 24 d5 2f 80 00 	movl   $0x802fd5,(%esp)
  80009d:	e8 e2 02 00 00       	call   800384 <_panic>

	if (pid == 0) {
  8000a2:	85 c0                	test   %eax,%eax
  8000a4:	0f 85 d5 00 00 00    	jne    80017f <umain+0x14b>
		cprintf("[%08x] pipereadeof close %d\n", env->env_id, p[1]);
  8000aa:	a1 78 70 80 00       	mov    0x807078,%eax
  8000af:	8b 40 4c             	mov    0x4c(%eax),%eax
  8000b2:	8b 55 90             	mov    -0x70(%ebp),%edx
  8000b5:	89 54 24 08          	mov    %edx,0x8(%esp)
  8000b9:	89 44 24 04          	mov    %eax,0x4(%esp)
  8000bd:	c7 04 24 ee 2f 80 00 	movl   $0x802fee,(%esp)
  8000c4:	e8 80 03 00 00       	call   800449 <cprintf>
		close(p[1]);
  8000c9:	8b 45 90             	mov    -0x70(%ebp),%eax
  8000cc:	89 04 24             	mov    %eax,(%esp)
  8000cf:	e8 88 1b 00 00       	call   801c5c <close>
		cprintf("[%08x] pipereadeof readn %d\n", env->env_id, p[0]);
  8000d4:	a1 78 70 80 00       	mov    0x807078,%eax
  8000d9:	8b 40 4c             	mov    0x4c(%eax),%eax
  8000dc:	8b 55 8c             	mov    -0x74(%ebp),%edx
  8000df:	89 54 24 08          	mov    %edx,0x8(%esp)
  8000e3:	89 44 24 04          	mov    %eax,0x4(%esp)
  8000e7:	c7 04 24 0b 30 80 00 	movl   $0x80300b,(%esp)
  8000ee:	e8 56 03 00 00       	call   800449 <cprintf>
		i = readn(p[0], buf, sizeof buf-1);
  8000f3:	c7 44 24 08 63 00 00 	movl   $0x63,0x8(%esp)
  8000fa:	00 
  8000fb:	8d 45 94             	lea    -0x6c(%ebp),%eax
  8000fe:	89 44 24 04          	mov    %eax,0x4(%esp)
  800102:	8b 45 8c             	mov    -0x74(%ebp),%eax
  800105:	89 04 24             	mov    %eax,(%esp)
  800108:	e8 74 1a 00 00       	call   801b81 <readn>
  80010d:	89 c6                	mov    %eax,%esi
		if (i < 0)
  80010f:	85 c0                	test   %eax,%eax
  800111:	79 20                	jns    800133 <umain+0xff>
			panic("read: %e", i);
  800113:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800117:	c7 44 24 08 28 30 80 	movl   $0x803028,0x8(%esp)
  80011e:	00 
  80011f:	c7 44 24 04 19 00 00 	movl   $0x19,0x4(%esp)
  800126:	00 
  800127:	c7 04 24 d5 2f 80 00 	movl   $0x802fd5,(%esp)
  80012e:	e8 51 02 00 00       	call   800384 <_panic>
		buf[i] = 0;
  800133:	c6 44 05 94 00       	movb   $0x0,-0x6c(%ebp,%eax,1)
		if (strcmp(buf, msg) == 0)
  800138:	a1 00 70 80 00       	mov    0x807000,%eax
  80013d:	89 44 24 04          	mov    %eax,0x4(%esp)
  800141:	8d 45 94             	lea    -0x6c(%ebp),%eax
  800144:	89 04 24             	mov    %eax,(%esp)
  800147:	e8 5d 0a 00 00       	call   800ba9 <strcmp>
  80014c:	85 c0                	test   %eax,%eax
  80014e:	75 0e                	jne    80015e <umain+0x12a>
			cprintf("\npipe read closed properly\n");
  800150:	c7 04 24 31 30 80 00 	movl   $0x803031,(%esp)
  800157:	e8 ed 02 00 00       	call   800449 <cprintf>
  80015c:	eb 17                	jmp    800175 <umain+0x141>
		else
			cprintf("\ngot %d bytes: %s\n", i, buf);
  80015e:	8d 45 94             	lea    -0x6c(%ebp),%eax
  800161:	89 44 24 08          	mov    %eax,0x8(%esp)
  800165:	89 74 24 04          	mov    %esi,0x4(%esp)
  800169:	c7 04 24 4d 30 80 00 	movl   $0x80304d,(%esp)
  800170:	e8 d4 02 00 00       	call   800449 <cprintf>
		exit();
  800175:	e8 ee 01 00 00       	call   800368 <exit>
  80017a:	e9 ac 00 00 00       	jmp    80022b <umain+0x1f7>
	} else {
		cprintf("[%08x] pipereadeof close %d\n", env->env_id, p[0]);
  80017f:	a1 78 70 80 00       	mov    0x807078,%eax
  800184:	8b 40 4c             	mov    0x4c(%eax),%eax
  800187:	8b 55 8c             	mov    -0x74(%ebp),%edx
  80018a:	89 54 24 08          	mov    %edx,0x8(%esp)
  80018e:	89 44 24 04          	mov    %eax,0x4(%esp)
  800192:	c7 04 24 ee 2f 80 00 	movl   $0x802fee,(%esp)
  800199:	e8 ab 02 00 00       	call   800449 <cprintf>
		close(p[0]);
  80019e:	8b 45 8c             	mov    -0x74(%ebp),%eax
  8001a1:	89 04 24             	mov    %eax,(%esp)
  8001a4:	e8 b3 1a 00 00       	call   801c5c <close>
		cprintf("[%08x] pipereadeof write %d\n", env->env_id, p[1]);
  8001a9:	a1 78 70 80 00       	mov    0x807078,%eax
  8001ae:	8b 40 4c             	mov    0x4c(%eax),%eax
  8001b1:	8b 55 90             	mov    -0x70(%ebp),%edx
  8001b4:	89 54 24 08          	mov    %edx,0x8(%esp)
  8001b8:	89 44 24 04          	mov    %eax,0x4(%esp)
  8001bc:	c7 04 24 60 30 80 00 	movl   $0x803060,(%esp)
  8001c3:	e8 81 02 00 00       	call   800449 <cprintf>
		if ((i = write(p[1], msg, strlen(msg))) != strlen(msg))
  8001c8:	a1 00 70 80 00       	mov    0x807000,%eax
  8001cd:	89 04 24             	mov    %eax,(%esp)
  8001d0:	e8 fb 08 00 00       	call   800ad0 <strlen>
  8001d5:	89 44 24 08          	mov    %eax,0x8(%esp)
  8001d9:	a1 00 70 80 00       	mov    0x807000,%eax
  8001de:	89 44 24 04          	mov    %eax,0x4(%esp)
  8001e2:	8b 45 90             	mov    -0x70(%ebp),%eax
  8001e5:	89 04 24             	mov    %eax,(%esp)
  8001e8:	e8 2d 18 00 00       	call   801a1a <write>
  8001ed:	89 c6                	mov    %eax,%esi
  8001ef:	a1 00 70 80 00       	mov    0x807000,%eax
  8001f4:	89 04 24             	mov    %eax,(%esp)
  8001f7:	e8 d4 08 00 00       	call   800ad0 <strlen>
  8001fc:	39 c6                	cmp    %eax,%esi
  8001fe:	74 20                	je     800220 <umain+0x1ec>
			panic("write: %e", i);
  800200:	89 74 24 0c          	mov    %esi,0xc(%esp)
  800204:	c7 44 24 08 7d 30 80 	movl   $0x80307d,0x8(%esp)
  80020b:	00 
  80020c:	c7 44 24 04 25 00 00 	movl   $0x25,0x4(%esp)
  800213:	00 
  800214:	c7 04 24 d5 2f 80 00 	movl   $0x802fd5,(%esp)
  80021b:	e8 64 01 00 00       	call   800384 <_panic>
		close(p[1]);
  800220:	8b 45 90             	mov    -0x70(%ebp),%eax
  800223:	89 04 24             	mov    %eax,(%esp)
  800226:	e8 31 1a 00 00       	call   801c5c <close>
	}
	wait(pid);
  80022b:	89 1c 24             	mov    %ebx,(%esp)
  80022e:	e8 41 27 00 00       	call   802974 <wait>

	argv0 = "pipewriteeof";
  800233:	c7 05 7c 70 80 00 87 	movl   $0x803087,0x80707c
  80023a:	30 80 00 
	if ((i = pipe(p)) < 0)
  80023d:	8d 45 8c             	lea    -0x74(%ebp),%eax
  800240:	89 04 24             	mov    %eax,(%esp)
  800243:	e8 b1 25 00 00       	call   8027f9 <pipe>
  800248:	89 c6                	mov    %eax,%esi
  80024a:	85 c0                	test   %eax,%eax
  80024c:	79 20                	jns    80026e <umain+0x23a>
		panic("pipe: %e", i);
  80024e:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800252:	c7 44 24 08 cc 2f 80 	movl   $0x802fcc,0x8(%esp)
  800259:	00 
  80025a:	c7 44 24 04 2c 00 00 	movl   $0x2c,0x4(%esp)
  800261:	00 
  800262:	c7 04 24 d5 2f 80 00 	movl   $0x802fd5,(%esp)
  800269:	e8 16 01 00 00       	call   800384 <_panic>

	if ((pid = fork()) < 0)
  80026e:	e8 4f 11 00 00       	call   8013c2 <fork>
  800273:	89 c3                	mov    %eax,%ebx
  800275:	85 c0                	test   %eax,%eax
  800277:	79 20                	jns    800299 <umain+0x265>
		panic("fork: %e", i);
  800279:	89 74 24 0c          	mov    %esi,0xc(%esp)
  80027d:	c7 44 24 08 e5 2f 80 	movl   $0x802fe5,0x8(%esp)
  800284:	00 
  800285:	c7 44 24 04 2f 00 00 	movl   $0x2f,0x4(%esp)
  80028c:	00 
  80028d:	c7 04 24 d5 2f 80 00 	movl   $0x802fd5,(%esp)
  800294:	e8 eb 00 00 00       	call   800384 <_panic>

	if (pid == 0) {
  800299:	85 c0                	test   %eax,%eax
  80029b:	75 48                	jne    8002e5 <umain+0x2b1>
		close(p[0]);
  80029d:	8b 45 8c             	mov    -0x74(%ebp),%eax
  8002a0:	89 04 24             	mov    %eax,(%esp)
  8002a3:	e8 b4 19 00 00       	call   801c5c <close>
		while (1) {
			cprintf(".");
  8002a8:	c7 04 24 94 30 80 00 	movl   $0x803094,(%esp)
  8002af:	e8 95 01 00 00       	call   800449 <cprintf>
			if (write(p[1], "x", 1) != 1)
  8002b4:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  8002bb:	00 
  8002bc:	c7 44 24 04 96 30 80 	movl   $0x803096,0x4(%esp)
  8002c3:	00 
  8002c4:	8b 45 90             	mov    -0x70(%ebp),%eax
  8002c7:	89 04 24             	mov    %eax,(%esp)
  8002ca:	e8 4b 17 00 00       	call   801a1a <write>
  8002cf:	83 f8 01             	cmp    $0x1,%eax
  8002d2:	74 d4                	je     8002a8 <umain+0x274>
				break;
		}
		cprintf("\npipe write closed properly\n");
  8002d4:	c7 04 24 98 30 80 00 	movl   $0x803098,(%esp)
  8002db:	e8 69 01 00 00       	call   800449 <cprintf>
		exit();
  8002e0:	e8 83 00 00 00       	call   800368 <exit>
	}
	close(p[0]);
  8002e5:	8b 45 8c             	mov    -0x74(%ebp),%eax
  8002e8:	89 04 24             	mov    %eax,(%esp)
  8002eb:	e8 6c 19 00 00       	call   801c5c <close>
	close(p[1]);
  8002f0:	8b 45 90             	mov    -0x70(%ebp),%eax
  8002f3:	89 04 24             	mov    %eax,(%esp)
  8002f6:	e8 61 19 00 00       	call   801c5c <close>
	wait(pid);
  8002fb:	89 1c 24             	mov    %ebx,(%esp)
  8002fe:	e8 71 26 00 00       	call   802974 <wait>

	cprintf("pipe tests passed\n");
  800303:	c7 04 24 b5 30 80 00 	movl   $0x8030b5,(%esp)
  80030a:	e8 3a 01 00 00       	call   800449 <cprintf>
}
  80030f:	83 ec 80             	sub    $0xffffff80,%esp
  800312:	5b                   	pop    %ebx
  800313:	5e                   	pop    %esi
  800314:	5d                   	pop    %ebp
  800315:	c3                   	ret    
	...

00800318 <libmain>:
volatile struct Env *env;
char *binaryname = "(PROGRAM NAME UNKNOWN)";

void
libmain(int argc, char **argv)
{
  800318:	55                   	push   %ebp
  800319:	89 e5                	mov    %esp,%ebp
  80031b:	83 ec 18             	sub    $0x18,%esp
  80031e:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  800321:	89 75 fc             	mov    %esi,-0x4(%ebp)
  800324:	8b 75 08             	mov    0x8(%ebp),%esi
  800327:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	// set env to point at our env structure in envs[].
	// LAB 3: Your code here.
  envid_t envid   = sys_getenvid();
  80032a:	e8 da 0f 00 00       	call   801309 <sys_getenvid>
	env = &envs [ENVX(envid)];
  80032f:	25 ff 03 00 00       	and    $0x3ff,%eax
  800334:	6b c0 7c             	imul   $0x7c,%eax,%eax
  800337:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  80033c:	a3 78 70 80 00       	mov    %eax,0x807078

	// save the name of the program so that panic() can use it
	if (argc > 0)
  800341:	85 f6                	test   %esi,%esi
  800343:	7e 07                	jle    80034c <libmain+0x34>
		binaryname = argv[0];
  800345:	8b 03                	mov    (%ebx),%eax
  800347:	a3 04 70 80 00       	mov    %eax,0x807004

	// call user main routine
	umain(argc, argv);
  80034c:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800350:	89 34 24             	mov    %esi,(%esp)
  800353:	e8 dc fc ff ff       	call   800034 <umain>

	// exit gracefully
	exit();
  800358:	e8 0b 00 00 00       	call   800368 <exit>
}
  80035d:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  800360:	8b 75 fc             	mov    -0x4(%ebp),%esi
  800363:	89 ec                	mov    %ebp,%esp
  800365:	5d                   	pop    %ebp
  800366:	c3                   	ret    
	...

00800368 <exit>:

#include <inc/lib.h>

void
exit(void)
{
  800368:	55                   	push   %ebp
  800369:	89 e5                	mov    %esp,%ebp
  80036b:	83 ec 18             	sub    $0x18,%esp
	close_all();
  80036e:	e8 66 19 00 00       	call   801cd9 <close_all>
	sys_env_destroy(0);
  800373:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80037a:	e8 be 0f 00 00       	call   80133d <sys_env_destroy>
}
  80037f:	c9                   	leave  
  800380:	c3                   	ret    
  800381:	00 00                	add    %al,(%eax)
	...

00800384 <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
{
  800384:	55                   	push   %ebp
  800385:	89 e5                	mov    %esp,%ebp
  800387:	53                   	push   %ebx
  800388:	83 ec 14             	sub    $0x14,%esp
 * Panic is called on unresolvable fatal errors.
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
  80038b:	8d 5d 14             	lea    0x14(%ebp),%ebx
	va_list ap;

	va_start(ap, fmt);

	// Print the panic message
	if (argv0)
  80038e:	a1 7c 70 80 00       	mov    0x80707c,%eax
  800393:	85 c0                	test   %eax,%eax
  800395:	74 10                	je     8003a7 <_panic+0x23>
		cprintf("%s: ", argv0);
  800397:	89 44 24 04          	mov    %eax,0x4(%esp)
  80039b:	c7 04 24 23 31 80 00 	movl   $0x803123,(%esp)
  8003a2:	e8 a2 00 00 00       	call   800449 <cprintf>
	cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
  8003a7:	8b 45 0c             	mov    0xc(%ebp),%eax
  8003aa:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8003ae:	8b 45 08             	mov    0x8(%ebp),%eax
  8003b1:	89 44 24 08          	mov    %eax,0x8(%esp)
  8003b5:	a1 04 70 80 00       	mov    0x807004,%eax
  8003ba:	89 44 24 04          	mov    %eax,0x4(%esp)
  8003be:	c7 04 24 28 31 80 00 	movl   $0x803128,(%esp)
  8003c5:	e8 7f 00 00 00       	call   800449 <cprintf>
	vcprintf(fmt, ap);
  8003ca:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8003ce:	8b 45 10             	mov    0x10(%ebp),%eax
  8003d1:	89 04 24             	mov    %eax,(%esp)
  8003d4:	e8 0f 00 00 00       	call   8003e8 <vcprintf>
	cprintf("\n");
  8003d9:	c7 04 24 a7 34 80 00 	movl   $0x8034a7,(%esp)
  8003e0:	e8 64 00 00 00       	call   800449 <cprintf>

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  8003e5:	cc                   	int3   
  8003e6:	eb fd                	jmp    8003e5 <_panic+0x61>

008003e8 <vcprintf>:
	b->cnt++;
}

int
vcprintf(const char *fmt, va_list ap)
{
  8003e8:	55                   	push   %ebp
  8003e9:	89 e5                	mov    %esp,%ebp
  8003eb:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.idx = 0;
  8003f1:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  8003f8:	00 00 00 
	b.cnt = 0;
  8003fb:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  800402:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  800405:	8b 45 0c             	mov    0xc(%ebp),%eax
  800408:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80040c:	8b 45 08             	mov    0x8(%ebp),%eax
  80040f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800413:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  800419:	89 44 24 04          	mov    %eax,0x4(%esp)
  80041d:	c7 04 24 63 04 80 00 	movl   $0x800463,(%esp)
  800424:	e8 d4 01 00 00       	call   8005fd <vprintfmt>
	sys_cputs(b.buf, b.idx);
  800429:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  80042f:	89 44 24 04          	mov    %eax,0x4(%esp)
  800433:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  800439:	89 04 24             	mov    %eax,(%esp)
  80043c:	e8 cf 0a 00 00       	call   800f10 <sys_cputs>

	return b.cnt;
}
  800441:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  800447:	c9                   	leave  
  800448:	c3                   	ret    

00800449 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  800449:	55                   	push   %ebp
  80044a:	89 e5                	mov    %esp,%ebp
  80044c:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
cprintf(const char *fmt, ...)
  80044f:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vcprintf(fmt, ap);
  800452:	89 44 24 04          	mov    %eax,0x4(%esp)
  800456:	8b 45 08             	mov    0x8(%ebp),%eax
  800459:	89 04 24             	mov    %eax,(%esp)
  80045c:	e8 87 ff ff ff       	call   8003e8 <vcprintf>
	va_end(ap);

	return cnt;
}
  800461:	c9                   	leave  
  800462:	c3                   	ret    

00800463 <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  800463:	55                   	push   %ebp
  800464:	89 e5                	mov    %esp,%ebp
  800466:	53                   	push   %ebx
  800467:	83 ec 14             	sub    $0x14,%esp
  80046a:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  80046d:	8b 03                	mov    (%ebx),%eax
  80046f:	8b 55 08             	mov    0x8(%ebp),%edx
  800472:	88 54 03 08          	mov    %dl,0x8(%ebx,%eax,1)
  800476:	83 c0 01             	add    $0x1,%eax
  800479:	89 03                	mov    %eax,(%ebx)
	if (b->idx == 256-1) {
  80047b:	3d ff 00 00 00       	cmp    $0xff,%eax
  800480:	75 19                	jne    80049b <putch+0x38>
		sys_cputs(b->buf, b->idx);
  800482:	c7 44 24 04 ff 00 00 	movl   $0xff,0x4(%esp)
  800489:	00 
  80048a:	8d 43 08             	lea    0x8(%ebx),%eax
  80048d:	89 04 24             	mov    %eax,(%esp)
  800490:	e8 7b 0a 00 00       	call   800f10 <sys_cputs>
		b->idx = 0;
  800495:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
	}
	b->cnt++;
  80049b:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  80049f:	83 c4 14             	add    $0x14,%esp
  8004a2:	5b                   	pop    %ebx
  8004a3:	5d                   	pop    %ebp
  8004a4:	c3                   	ret    
	...

008004b0 <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  8004b0:	55                   	push   %ebp
  8004b1:	89 e5                	mov    %esp,%ebp
  8004b3:	57                   	push   %edi
  8004b4:	56                   	push   %esi
  8004b5:	53                   	push   %ebx
  8004b6:	83 ec 4c             	sub    $0x4c,%esp
  8004b9:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  8004bc:	89 d6                	mov    %edx,%esi
  8004be:	8b 45 08             	mov    0x8(%ebp),%eax
  8004c1:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8004c4:	8b 55 0c             	mov    0xc(%ebp),%edx
  8004c7:	89 55 e0             	mov    %edx,-0x20(%ebp)
  8004ca:	8b 45 10             	mov    0x10(%ebp),%eax
  8004cd:	8b 5d 14             	mov    0x14(%ebp),%ebx
  8004d0:	8b 7d 18             	mov    0x18(%ebp),%edi
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  8004d3:	89 45 dc             	mov    %eax,-0x24(%ebp)
  8004d6:	b9 00 00 00 00       	mov    $0x0,%ecx
  8004db:	39 d1                	cmp    %edx,%ecx
  8004dd:	72 15                	jb     8004f4 <printnum+0x44>
  8004df:	77 07                	ja     8004e8 <printnum+0x38>
  8004e1:	8b 55 d8             	mov    -0x28(%ebp),%edx
  8004e4:	39 d0                	cmp    %edx,%eax
  8004e6:	76 0c                	jbe    8004f4 <printnum+0x44>
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  8004e8:	83 eb 01             	sub    $0x1,%ebx
  8004eb:	85 db                	test   %ebx,%ebx
  8004ed:	8d 76 00             	lea    0x0(%esi),%esi
  8004f0:	7f 61                	jg     800553 <printnum+0xa3>
  8004f2:	eb 70                	jmp    800564 <printnum+0xb4>
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
  8004f4:	89 7c 24 10          	mov    %edi,0x10(%esp)
  8004f8:	83 eb 01             	sub    $0x1,%ebx
  8004fb:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8004ff:	89 44 24 08          	mov    %eax,0x8(%esp)
  800503:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  800507:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
  80050b:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  80050e:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
  800511:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800514:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800518:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80051f:	00 
  800520:	8b 45 d8             	mov    -0x28(%ebp),%eax
  800523:	89 04 24             	mov    %eax,(%esp)
  800526:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800529:	89 54 24 04          	mov    %edx,0x4(%esp)
  80052d:	e8 0e 28 00 00       	call   802d40 <__udivdi3>
  800532:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  800535:	8b 5d d4             	mov    -0x2c(%ebp),%ebx
  800538:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  80053c:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  800540:	89 04 24             	mov    %eax,(%esp)
  800543:	89 54 24 04          	mov    %edx,0x4(%esp)
  800547:	89 f2                	mov    %esi,%edx
  800549:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80054c:	e8 5f ff ff ff       	call   8004b0 <printnum>
  800551:	eb 11                	jmp    800564 <printnum+0xb4>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  800553:	89 74 24 04          	mov    %esi,0x4(%esp)
  800557:	89 3c 24             	mov    %edi,(%esp)
  80055a:	ff 55 e4             	call   *-0x1c(%ebp)
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  80055d:	83 eb 01             	sub    $0x1,%ebx
  800560:	85 db                	test   %ebx,%ebx
  800562:	7f ef                	jg     800553 <printnum+0xa3>
			putch(padc, putdat);
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  800564:	89 74 24 04          	mov    %esi,0x4(%esp)
  800568:	8b 74 24 04          	mov    0x4(%esp),%esi
  80056c:	8b 45 dc             	mov    -0x24(%ebp),%eax
  80056f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800573:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80057a:	00 
  80057b:	8b 55 d8             	mov    -0x28(%ebp),%edx
  80057e:	89 14 24             	mov    %edx,(%esp)
  800581:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800584:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800588:	e8 e3 28 00 00       	call   802e70 <__umoddi3>
  80058d:	89 74 24 04          	mov    %esi,0x4(%esp)
  800591:	0f be 80 44 31 80 00 	movsbl 0x803144(%eax),%eax
  800598:	89 04 24             	mov    %eax,(%esp)
  80059b:	ff 55 e4             	call   *-0x1c(%ebp)
}
  80059e:	83 c4 4c             	add    $0x4c,%esp
  8005a1:	5b                   	pop    %ebx
  8005a2:	5e                   	pop    %esi
  8005a3:	5f                   	pop    %edi
  8005a4:	5d                   	pop    %ebp
  8005a5:	c3                   	ret    

008005a6 <getuint>:

// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
  8005a6:	55                   	push   %ebp
  8005a7:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2)
  8005a9:	83 fa 01             	cmp    $0x1,%edx
  8005ac:	7e 0e                	jle    8005bc <getuint+0x16>
		return va_arg(*ap, unsigned long long);
  8005ae:	8b 10                	mov    (%eax),%edx
  8005b0:	8d 4a 08             	lea    0x8(%edx),%ecx
  8005b3:	89 08                	mov    %ecx,(%eax)
  8005b5:	8b 02                	mov    (%edx),%eax
  8005b7:	8b 52 04             	mov    0x4(%edx),%edx
  8005ba:	eb 22                	jmp    8005de <getuint+0x38>
	else if (lflag)
  8005bc:	85 d2                	test   %edx,%edx
  8005be:	74 10                	je     8005d0 <getuint+0x2a>
		return va_arg(*ap, unsigned long);
  8005c0:	8b 10                	mov    (%eax),%edx
  8005c2:	8d 4a 04             	lea    0x4(%edx),%ecx
  8005c5:	89 08                	mov    %ecx,(%eax)
  8005c7:	8b 02                	mov    (%edx),%eax
  8005c9:	ba 00 00 00 00       	mov    $0x0,%edx
  8005ce:	eb 0e                	jmp    8005de <getuint+0x38>
	else
		return va_arg(*ap, unsigned int);
  8005d0:	8b 10                	mov    (%eax),%edx
  8005d2:	8d 4a 04             	lea    0x4(%edx),%ecx
  8005d5:	89 08                	mov    %ecx,(%eax)
  8005d7:	8b 02                	mov    (%edx),%eax
  8005d9:	ba 00 00 00 00       	mov    $0x0,%edx
}
  8005de:	5d                   	pop    %ebp
  8005df:	c3                   	ret    

008005e0 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  8005e0:	55                   	push   %ebp
  8005e1:	89 e5                	mov    %esp,%ebp
  8005e3:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  8005e6:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  8005ea:	8b 10                	mov    (%eax),%edx
  8005ec:	3b 50 04             	cmp    0x4(%eax),%edx
  8005ef:	73 0a                	jae    8005fb <sprintputch+0x1b>
		*b->buf++ = ch;
  8005f1:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8005f4:	88 0a                	mov    %cl,(%edx)
  8005f6:	83 c2 01             	add    $0x1,%edx
  8005f9:	89 10                	mov    %edx,(%eax)
}
  8005fb:	5d                   	pop    %ebp
  8005fc:	c3                   	ret    

008005fd <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);

void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
  8005fd:	55                   	push   %ebp
  8005fe:	89 e5                	mov    %esp,%ebp
  800600:	57                   	push   %edi
  800601:	56                   	push   %esi
  800602:	53                   	push   %ebx
  800603:	83 ec 5c             	sub    $0x5c,%esp
  800606:	8b 7d 08             	mov    0x8(%ebp),%edi
  800609:	8b 75 0c             	mov    0xc(%ebp),%esi
  80060c:	8b 5d 10             	mov    0x10(%ebp),%ebx
		case '#':
			altflag = 1;
			goto reswitch;

		process_precision:
			if (width < 0)
  80060f:	c7 45 c8 ff ff ff ff 	movl   $0xffffffff,-0x38(%ebp)
  800616:	eb 11                	jmp    800629 <vprintfmt+0x2c>
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
			if (ch == '\0')
  800618:	85 c0                	test   %eax,%eax
  80061a:	0f 84 f9 03 00 00    	je     800a19 <vprintfmt+0x41c>
				return;
			putch(ch, putdat);
  800620:	89 74 24 04          	mov    %esi,0x4(%esp)
  800624:	89 04 24             	mov    %eax,(%esp)
  800627:	ff d7                	call   *%edi
	unsigned long long num;
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
  800629:	0f b6 03             	movzbl (%ebx),%eax
  80062c:	83 c3 01             	add    $0x1,%ebx
  80062f:	83 f8 25             	cmp    $0x25,%eax
  800632:	75 e4                	jne    800618 <vprintfmt+0x1b>
  800634:	c6 45 d4 20          	movb   $0x20,-0x2c(%ebp)
  800638:	c7 45 d8 00 00 00 00 	movl   $0x0,-0x28(%ebp)
  80063f:	c7 45 d0 ff ff ff ff 	movl   $0xffffffff,-0x30(%ebp)
  800646:	c7 45 e4 ff ff ff ff 	movl   $0xffffffff,-0x1c(%ebp)
  80064d:	b9 00 00 00 00       	mov    $0x0,%ecx
  800652:	eb 06                	jmp    80065a <vprintfmt+0x5d>
  800654:	c6 45 d4 2d          	movb   $0x2d,-0x2c(%ebp)
  800658:	89 c3                	mov    %eax,%ebx
		width = -1;
		precision = -1;
		lflag = 0;
		altflag = 0;
	reswitch:
		switch (ch = *(unsigned char *) fmt++) {
  80065a:	0f b6 13             	movzbl (%ebx),%edx
  80065d:	0f b6 c2             	movzbl %dl,%eax
  800660:	89 45 e0             	mov    %eax,-0x20(%ebp)
  800663:	8d 43 01             	lea    0x1(%ebx),%eax
  800666:	83 ea 23             	sub    $0x23,%edx
  800669:	80 fa 55             	cmp    $0x55,%dl
  80066c:	0f 87 8a 03 00 00    	ja     8009fc <vprintfmt+0x3ff>
  800672:	0f b6 d2             	movzbl %dl,%edx
  800675:	ff 24 95 80 32 80 00 	jmp    *0x803280(,%edx,4)
  80067c:	c6 45 d4 30          	movb   $0x30,-0x2c(%ebp)
  800680:	eb d6                	jmp    800658 <vprintfmt+0x5b>
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
				precision = precision * 10 + ch - '0';
  800682:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800685:	83 ea 30             	sub    $0x30,%edx
  800688:	89 55 d0             	mov    %edx,-0x30(%ebp)
				ch = *fmt;
  80068b:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  80068e:	8d 5a d0             	lea    -0x30(%edx),%ebx
  800691:	83 fb 09             	cmp    $0x9,%ebx
  800694:	77 54                	ja     8006ea <vprintfmt+0xed>
  800696:	89 4d e0             	mov    %ecx,-0x20(%ebp)
  800699:	8b 4d d0             	mov    -0x30(%ebp),%ecx
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
  80069c:	83 c0 01             	add    $0x1,%eax
				precision = precision * 10 + ch - '0';
  80069f:	8d 0c 89             	lea    (%ecx,%ecx,4),%ecx
  8006a2:	8d 4c 4a d0          	lea    -0x30(%edx,%ecx,2),%ecx
				ch = *fmt;
  8006a6:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  8006a9:	8d 5a d0             	lea    -0x30(%edx),%ebx
  8006ac:	83 fb 09             	cmp    $0x9,%ebx
  8006af:	76 eb                	jbe    80069c <vprintfmt+0x9f>
  8006b1:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  8006b4:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  8006b7:	eb 31                	jmp    8006ea <vprintfmt+0xed>
					break;
			}
			goto process_precision;

		case '*':
			precision = va_arg(ap, int);
  8006b9:	8b 55 14             	mov    0x14(%ebp),%edx
  8006bc:	8d 5a 04             	lea    0x4(%edx),%ebx
  8006bf:	89 5d 14             	mov    %ebx,0x14(%ebp)
  8006c2:	8b 12                	mov    (%edx),%edx
  8006c4:	89 55 d0             	mov    %edx,-0x30(%ebp)
			goto process_precision;
  8006c7:	eb 21                	jmp    8006ea <vprintfmt+0xed>

		case '.':
			if (width < 0)
  8006c9:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8006cd:	ba 00 00 00 00       	mov    $0x0,%edx
  8006d2:	0f 49 55 e4          	cmovns -0x1c(%ebp),%edx
  8006d6:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8006d9:	e9 7a ff ff ff       	jmp    800658 <vprintfmt+0x5b>
  8006de:	c7 45 d8 01 00 00 00 	movl   $0x1,-0x28(%ebp)
				width = 0;
			goto reswitch;

		case '#':
			altflag = 1;
			goto reswitch;
  8006e5:	e9 6e ff ff ff       	jmp    800658 <vprintfmt+0x5b>

		process_precision:
			if (width < 0)
  8006ea:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8006ee:	0f 89 64 ff ff ff    	jns    800658 <vprintfmt+0x5b>
  8006f4:	8b 55 d0             	mov    -0x30(%ebp),%edx
  8006f7:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8006fa:	8b 55 c8             	mov    -0x38(%ebp),%edx
  8006fd:	89 55 d0             	mov    %edx,-0x30(%ebp)
  800700:	e9 53 ff ff ff       	jmp    800658 <vprintfmt+0x5b>
				width = precision, precision = -1;
			goto reswitch;

		// long flag (doubled for long long)
		case 'l':
			lflag++;
  800705:	83 c1 01             	add    $0x1,%ecx
			goto reswitch;
  800708:	e9 4b ff ff ff       	jmp    800658 <vprintfmt+0x5b>
  80070d:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// character
		case 'c':
			putch(va_arg(ap, int), putdat);
  800710:	8b 45 14             	mov    0x14(%ebp),%eax
  800713:	8d 50 04             	lea    0x4(%eax),%edx
  800716:	89 55 14             	mov    %edx,0x14(%ebp)
  800719:	89 74 24 04          	mov    %esi,0x4(%esp)
  80071d:	8b 00                	mov    (%eax),%eax
  80071f:	89 04 24             	mov    %eax,(%esp)
  800722:	ff d7                	call   *%edi
  800724:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800727:	e9 fd fe ff ff       	jmp    800629 <vprintfmt+0x2c>
  80072c:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// error message
		case 'e':
			err = va_arg(ap, int);
  80072f:	8b 45 14             	mov    0x14(%ebp),%eax
  800732:	8d 50 04             	lea    0x4(%eax),%edx
  800735:	89 55 14             	mov    %edx,0x14(%ebp)
  800738:	8b 00                	mov    (%eax),%eax
  80073a:	89 c2                	mov    %eax,%edx
  80073c:	c1 fa 1f             	sar    $0x1f,%edx
  80073f:	31 d0                	xor    %edx,%eax
  800741:	29 d0                	sub    %edx,%eax
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  800743:	83 f8 12             	cmp    $0x12,%eax
  800746:	7f 0b                	jg     800753 <vprintfmt+0x156>
  800748:	8b 14 85 e0 33 80 00 	mov    0x8033e0(,%eax,4),%edx
  80074f:	85 d2                	test   %edx,%edx
  800751:	75 20                	jne    800773 <vprintfmt+0x176>
				printfmt(putch, putdat, "error %d", err);
  800753:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800757:	c7 44 24 08 55 31 80 	movl   $0x803155,0x8(%esp)
  80075e:	00 
  80075f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800763:	89 3c 24             	mov    %edi,(%esp)
  800766:	e8 36 03 00 00       	call   800aa1 <printfmt>
  80076b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
		// error message
		case 'e':
			err = va_arg(ap, int);
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  80076e:	e9 b6 fe ff ff       	jmp    800629 <vprintfmt+0x2c>
				printfmt(putch, putdat, "error %d", err);
			else
				printfmt(putch, putdat, "%s", p);
  800773:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800777:	c7 44 24 08 f2 36 80 	movl   $0x8036f2,0x8(%esp)
  80077e:	00 
  80077f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800783:	89 3c 24             	mov    %edi,(%esp)
  800786:	e8 16 03 00 00       	call   800aa1 <printfmt>
  80078b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80078e:	e9 96 fe ff ff       	jmp    800629 <vprintfmt+0x2c>
  800793:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800796:	89 c3                	mov    %eax,%ebx
  800798:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  80079b:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80079e:	89 45 c4             	mov    %eax,-0x3c(%ebp)
			break;

		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
  8007a1:	8b 45 14             	mov    0x14(%ebp),%eax
  8007a4:	8d 50 04             	lea    0x4(%eax),%edx
  8007a7:	89 55 14             	mov    %edx,0x14(%ebp)
  8007aa:	8b 00                	mov    (%eax),%eax
  8007ac:	89 45 e0             	mov    %eax,-0x20(%ebp)
  8007af:	85 c0                	test   %eax,%eax
  8007b1:	b8 5e 31 80 00       	mov    $0x80315e,%eax
  8007b6:	0f 45 45 e0          	cmovne -0x20(%ebp),%eax
  8007ba:	89 45 e0             	mov    %eax,-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
  8007bd:	83 7d c4 00          	cmpl   $0x0,-0x3c(%ebp)
  8007c1:	7e 06                	jle    8007c9 <vprintfmt+0x1cc>
  8007c3:	80 7d d4 2d          	cmpb   $0x2d,-0x2c(%ebp)
  8007c7:	75 13                	jne    8007dc <vprintfmt+0x1df>
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8007c9:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8007cc:	0f be 02             	movsbl (%edx),%eax
  8007cf:	85 c0                	test   %eax,%eax
  8007d1:	0f 85 9b 00 00 00    	jne    800872 <vprintfmt+0x275>
  8007d7:	e9 88 00 00 00       	jmp    800864 <vprintfmt+0x267>
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  8007dc:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  8007e0:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  8007e3:	89 0c 24             	mov    %ecx,(%esp)
  8007e6:	e8 00 03 00 00       	call   800aeb <strnlen>
  8007eb:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  8007ee:	29 c2                	sub    %eax,%edx
  8007f0:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8007f3:	85 d2                	test   %edx,%edx
  8007f5:	7e d2                	jle    8007c9 <vprintfmt+0x1cc>
					putch(padc, putdat);
  8007f7:	0f be 4d d4          	movsbl -0x2c(%ebp),%ecx
  8007fb:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
  8007fe:	89 5d c4             	mov    %ebx,-0x3c(%ebp)
  800801:	89 d3                	mov    %edx,%ebx
  800803:	89 74 24 04          	mov    %esi,0x4(%esp)
  800807:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  80080a:	89 04 24             	mov    %eax,(%esp)
  80080d:	ff d7                	call   *%edi
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80080f:	83 eb 01             	sub    $0x1,%ebx
  800812:	85 db                	test   %ebx,%ebx
  800814:	7f ed                	jg     800803 <vprintfmt+0x206>
  800816:	8b 5d c4             	mov    -0x3c(%ebp),%ebx
  800819:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  800820:	eb a7                	jmp    8007c9 <vprintfmt+0x1cc>
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  800822:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  800826:	74 1a                	je     800842 <vprintfmt+0x245>
  800828:	8d 50 e0             	lea    -0x20(%eax),%edx
  80082b:	83 fa 5e             	cmp    $0x5e,%edx
  80082e:	76 12                	jbe    800842 <vprintfmt+0x245>
					putch('?', putdat);
  800830:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800834:	c7 04 24 3f 00 00 00 	movl   $0x3f,(%esp)
  80083b:	ff 55 e0             	call   *-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  80083e:	66 90                	xchg   %ax,%ax
  800840:	eb 0a                	jmp    80084c <vprintfmt+0x24f>
					putch('?', putdat);
				else
					putch(ch, putdat);
  800842:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800846:	89 04 24             	mov    %eax,(%esp)
  800849:	ff 55 e0             	call   *-0x20(%ebp)
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  80084c:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  800850:	0f be 03             	movsbl (%ebx),%eax
  800853:	85 c0                	test   %eax,%eax
  800855:	74 05                	je     80085c <vprintfmt+0x25f>
  800857:	83 c3 01             	add    $0x1,%ebx
  80085a:	eb 29                	jmp    800885 <vprintfmt+0x288>
  80085c:	89 fe                	mov    %edi,%esi
  80085e:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800861:	8b 5d d0             	mov    -0x30(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  800864:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  800868:	7f 2e                	jg     800898 <vprintfmt+0x29b>
  80086a:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80086d:	e9 b7 fd ff ff       	jmp    800629 <vprintfmt+0x2c>
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800872:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800875:	83 c2 01             	add    $0x1,%edx
  800878:	89 7d e0             	mov    %edi,-0x20(%ebp)
  80087b:	89 f7                	mov    %esi,%edi
  80087d:	8b 75 d0             	mov    -0x30(%ebp),%esi
  800880:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  800883:	89 d3                	mov    %edx,%ebx
  800885:	85 f6                	test   %esi,%esi
  800887:	78 99                	js     800822 <vprintfmt+0x225>
  800889:	83 ee 01             	sub    $0x1,%esi
  80088c:	79 94                	jns    800822 <vprintfmt+0x225>
  80088e:	89 fe                	mov    %edi,%esi
  800890:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800893:	8b 5d d0             	mov    -0x30(%ebp),%ebx
  800896:	eb cc                	jmp    800864 <vprintfmt+0x267>
  800898:	89 5d d8             	mov    %ebx,-0x28(%ebp)
  80089b:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
				putch(' ', putdat);
  80089e:	89 74 24 04          	mov    %esi,0x4(%esp)
  8008a2:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  8008a9:	ff d7                	call   *%edi
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  8008ab:	83 eb 01             	sub    $0x1,%ebx
  8008ae:	85 db                	test   %ebx,%ebx
  8008b0:	7f ec                	jg     80089e <vprintfmt+0x2a1>
  8008b2:	8b 5d d8             	mov    -0x28(%ebp),%ebx
  8008b5:	e9 6f fd ff ff       	jmp    800629 <vprintfmt+0x2c>
  8008ba:	89 45 cc             	mov    %eax,-0x34(%ebp)
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
	if (lflag >= 2)
  8008bd:	83 f9 01             	cmp    $0x1,%ecx
  8008c0:	7e 16                	jle    8008d8 <vprintfmt+0x2db>
		return va_arg(*ap, long long);
  8008c2:	8b 45 14             	mov    0x14(%ebp),%eax
  8008c5:	8d 50 08             	lea    0x8(%eax),%edx
  8008c8:	89 55 14             	mov    %edx,0x14(%ebp)
  8008cb:	8b 10                	mov    (%eax),%edx
  8008cd:	8b 48 04             	mov    0x4(%eax),%ecx
  8008d0:	89 55 d8             	mov    %edx,-0x28(%ebp)
  8008d3:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  8008d6:	eb 32                	jmp    80090a <vprintfmt+0x30d>
	else if (lflag)
  8008d8:	85 c9                	test   %ecx,%ecx
  8008da:	74 18                	je     8008f4 <vprintfmt+0x2f7>
		return va_arg(*ap, long);
  8008dc:	8b 45 14             	mov    0x14(%ebp),%eax
  8008df:	8d 50 04             	lea    0x4(%eax),%edx
  8008e2:	89 55 14             	mov    %edx,0x14(%ebp)
  8008e5:	8b 00                	mov    (%eax),%eax
  8008e7:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8008ea:	89 c1                	mov    %eax,%ecx
  8008ec:	c1 f9 1f             	sar    $0x1f,%ecx
  8008ef:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  8008f2:	eb 16                	jmp    80090a <vprintfmt+0x30d>
	else
		return va_arg(*ap, int);
  8008f4:	8b 45 14             	mov    0x14(%ebp),%eax
  8008f7:	8d 50 04             	lea    0x4(%eax),%edx
  8008fa:	89 55 14             	mov    %edx,0x14(%ebp)
  8008fd:	8b 00                	mov    (%eax),%eax
  8008ff:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800902:	89 c2                	mov    %eax,%edx
  800904:	c1 fa 1f             	sar    $0x1f,%edx
  800907:	89 55 dc             	mov    %edx,-0x24(%ebp)
				putch(' ', putdat);
			break;

		// (signed) decimal
		case 'd':
			num = getint(&ap, lflag);
  80090a:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  80090d:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800910:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  800915:	83 7d dc 00          	cmpl   $0x0,-0x24(%ebp)
  800919:	0f 89 9b 00 00 00    	jns    8009ba <vprintfmt+0x3bd>
				putch('-', putdat);
  80091f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800923:	c7 04 24 2d 00 00 00 	movl   $0x2d,(%esp)
  80092a:	ff d7                	call   *%edi
				num = -(long long) num;
  80092c:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  80092f:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800932:	f7 d9                	neg    %ecx
  800934:	83 d3 00             	adc    $0x0,%ebx
  800937:	f7 db                	neg    %ebx
  800939:	b8 0a 00 00 00       	mov    $0xa,%eax
  80093e:	eb 7a                	jmp    8009ba <vprintfmt+0x3bd>
  800940:	89 45 cc             	mov    %eax,-0x34(%ebp)
			base = 10;
			goto number;

		// unsigned decimal
		case 'u':
			num = getuint(&ap, lflag);
  800943:	89 ca                	mov    %ecx,%edx
  800945:	8d 45 14             	lea    0x14(%ebp),%eax
  800948:	e8 59 fc ff ff       	call   8005a6 <getuint>
  80094d:	89 c1                	mov    %eax,%ecx
  80094f:	89 d3                	mov    %edx,%ebx
  800951:	b8 0a 00 00 00       	mov    $0xa,%eax
			base = 10;
			goto number;
  800956:	eb 62                	jmp    8009ba <vprintfmt+0x3bd>
  800958:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) octal
		case 'o':
			num = getuint(&ap, lflag);
  80095b:	89 ca                	mov    %ecx,%edx
  80095d:	8d 45 14             	lea    0x14(%ebp),%eax
  800960:	e8 41 fc ff ff       	call   8005a6 <getuint>
  800965:	89 c1                	mov    %eax,%ecx
  800967:	89 d3                	mov    %edx,%ebx
  800969:	b8 08 00 00 00       	mov    $0x8,%eax
			base = 8;
			goto number;
  80096e:	eb 4a                	jmp    8009ba <vprintfmt+0x3bd>
  800970:	89 45 cc             	mov    %eax,-0x34(%ebp)
			break;
			**/

		// pointer
		case 'p':
			putch('0', putdat);
  800973:	89 74 24 04          	mov    %esi,0x4(%esp)
  800977:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  80097e:	ff d7                	call   *%edi
			putch('x', putdat);
  800980:	89 74 24 04          	mov    %esi,0x4(%esp)
  800984:	c7 04 24 78 00 00 00 	movl   $0x78,(%esp)
  80098b:	ff d7                	call   *%edi
			num = (unsigned long long)
  80098d:	8b 45 14             	mov    0x14(%ebp),%eax
  800990:	8d 50 04             	lea    0x4(%eax),%edx
  800993:	89 55 14             	mov    %edx,0x14(%ebp)
  800996:	8b 08                	mov    (%eax),%ecx
  800998:	bb 00 00 00 00       	mov    $0x0,%ebx
  80099d:	b8 10 00 00 00       	mov    $0x10,%eax
				(uintptr_t) va_arg(ap, void *);
			base = 16;
			goto number;
  8009a2:	eb 16                	jmp    8009ba <vprintfmt+0x3bd>
  8009a4:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) hexadecimal
		case 'x':
			num = getuint(&ap, lflag);
  8009a7:	89 ca                	mov    %ecx,%edx
  8009a9:	8d 45 14             	lea    0x14(%ebp),%eax
  8009ac:	e8 f5 fb ff ff       	call   8005a6 <getuint>
  8009b1:	89 c1                	mov    %eax,%ecx
  8009b3:	89 d3                	mov    %edx,%ebx
  8009b5:	b8 10 00 00 00       	mov    $0x10,%eax
			base = 16;
		number:
			printnum(putch, putdat, num, base, width, padc);
  8009ba:	0f be 55 d4          	movsbl -0x2c(%ebp),%edx
  8009be:	89 54 24 10          	mov    %edx,0x10(%esp)
  8009c2:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8009c5:	89 54 24 0c          	mov    %edx,0xc(%esp)
  8009c9:	89 44 24 08          	mov    %eax,0x8(%esp)
  8009cd:	89 0c 24             	mov    %ecx,(%esp)
  8009d0:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8009d4:	89 f2                	mov    %esi,%edx
  8009d6:	89 f8                	mov    %edi,%eax
  8009d8:	e8 d3 fa ff ff       	call   8004b0 <printnum>
  8009dd:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  8009e0:	e9 44 fc ff ff       	jmp    800629 <vprintfmt+0x2c>
  8009e5:	89 45 cc             	mov    %eax,-0x34(%ebp)
  8009e8:	8b 55 e0             	mov    -0x20(%ebp),%edx

		// escaped '%' character
		case '%':
			putch(ch, putdat);
  8009eb:	89 74 24 04          	mov    %esi,0x4(%esp)
  8009ef:	89 14 24             	mov    %edx,(%esp)
  8009f2:	ff d7                	call   *%edi
  8009f4:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  8009f7:	e9 2d fc ff ff       	jmp    800629 <vprintfmt+0x2c>
			
		// unrecognized escape sequence - just print it literally
		default:
			putch('%', putdat);
  8009fc:	89 74 24 04          	mov    %esi,0x4(%esp)
  800a00:	c7 04 24 25 00 00 00 	movl   $0x25,(%esp)
  800a07:	ff d7                	call   *%edi
			for (fmt--; fmt[-1] != '%'; fmt--)
  800a09:	8d 43 ff             	lea    -0x1(%ebx),%eax
  800a0c:	80 38 25             	cmpb   $0x25,(%eax)
  800a0f:	0f 84 14 fc ff ff    	je     800629 <vprintfmt+0x2c>
  800a15:	89 c3                	mov    %eax,%ebx
  800a17:	eb f0                	jmp    800a09 <vprintfmt+0x40c>
				/* do nothing */;
			break;
		}
	}
}
  800a19:	83 c4 5c             	add    $0x5c,%esp
  800a1c:	5b                   	pop    %ebx
  800a1d:	5e                   	pop    %esi
  800a1e:	5f                   	pop    %edi
  800a1f:	5d                   	pop    %ebp
  800a20:	c3                   	ret    

00800a21 <vsnprintf>:
		*b->buf++ = ch;
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  800a21:	55                   	push   %ebp
  800a22:	89 e5                	mov    %esp,%ebp
  800a24:	83 ec 28             	sub    $0x28,%esp
  800a27:	8b 45 08             	mov    0x8(%ebp),%eax
  800a2a:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};

	if (buf == NULL || n < 1)
  800a2d:	85 c0                	test   %eax,%eax
  800a2f:	74 04                	je     800a35 <vsnprintf+0x14>
  800a31:	85 d2                	test   %edx,%edx
  800a33:	7f 07                	jg     800a3c <vsnprintf+0x1b>
  800a35:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  800a3a:	eb 3b                	jmp    800a77 <vsnprintf+0x56>
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
	struct sprintbuf b = {buf, buf+n-1, 0};
  800a3c:	89 45 ec             	mov    %eax,-0x14(%ebp)
  800a3f:	8d 44 10 ff          	lea    -0x1(%eax,%edx,1),%eax
  800a43:	89 45 f0             	mov    %eax,-0x10(%ebp)
  800a46:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  800a4d:	8b 45 14             	mov    0x14(%ebp),%eax
  800a50:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800a54:	8b 45 10             	mov    0x10(%ebp),%eax
  800a57:	89 44 24 08          	mov    %eax,0x8(%esp)
  800a5b:	8d 45 ec             	lea    -0x14(%ebp),%eax
  800a5e:	89 44 24 04          	mov    %eax,0x4(%esp)
  800a62:	c7 04 24 e0 05 80 00 	movl   $0x8005e0,(%esp)
  800a69:	e8 8f fb ff ff       	call   8005fd <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  800a6e:	8b 45 ec             	mov    -0x14(%ebp),%eax
  800a71:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  800a74:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  800a77:	c9                   	leave  
  800a78:	c3                   	ret    

00800a79 <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  800a79:	55                   	push   %ebp
  800a7a:	89 e5                	mov    %esp,%ebp
  800a7c:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
snprintf(char *buf, int n, const char *fmt, ...)
  800a7f:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;
	int rc;

	va_start(ap, fmt);
	rc = vsnprintf(buf, n, fmt, ap);
  800a82:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800a86:	8b 45 10             	mov    0x10(%ebp),%eax
  800a89:	89 44 24 08          	mov    %eax,0x8(%esp)
  800a8d:	8b 45 0c             	mov    0xc(%ebp),%eax
  800a90:	89 44 24 04          	mov    %eax,0x4(%esp)
  800a94:	8b 45 08             	mov    0x8(%ebp),%eax
  800a97:	89 04 24             	mov    %eax,(%esp)
  800a9a:	e8 82 ff ff ff       	call   800a21 <vsnprintf>
	va_end(ap);

	return rc;
}
  800a9f:	c9                   	leave  
  800aa0:	c3                   	ret    

00800aa1 <printfmt>:
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
  800aa1:	55                   	push   %ebp
  800aa2:	89 e5                	mov    %esp,%ebp
  800aa4:	83 ec 18             	sub    $0x18,%esp
		}
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
  800aa7:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;

	va_start(ap, fmt);
	vprintfmt(putch, putdat, fmt, ap);
  800aaa:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800aae:	8b 45 10             	mov    0x10(%ebp),%eax
  800ab1:	89 44 24 08          	mov    %eax,0x8(%esp)
  800ab5:	8b 45 0c             	mov    0xc(%ebp),%eax
  800ab8:	89 44 24 04          	mov    %eax,0x4(%esp)
  800abc:	8b 45 08             	mov    0x8(%ebp),%eax
  800abf:	89 04 24             	mov    %eax,(%esp)
  800ac2:	e8 36 fb ff ff       	call   8005fd <vprintfmt>
	va_end(ap);
}
  800ac7:	c9                   	leave  
  800ac8:	c3                   	ret    
  800ac9:	00 00                	add    %al,(%eax)
  800acb:	00 00                	add    %al,(%eax)
  800acd:	00 00                	add    %al,(%eax)
	...

00800ad0 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  800ad0:	55                   	push   %ebp
  800ad1:	89 e5                	mov    %esp,%ebp
  800ad3:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  800ad6:	b8 00 00 00 00       	mov    $0x0,%eax
  800adb:	80 3a 00             	cmpb   $0x0,(%edx)
  800ade:	74 09                	je     800ae9 <strlen+0x19>
		n++;
  800ae0:	83 c0 01             	add    $0x1,%eax
int
strlen(const char *s)
{
	int n;

	for (n = 0; *s != '\0'; s++)
  800ae3:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  800ae7:	75 f7                	jne    800ae0 <strlen+0x10>
		n++;
	return n;
}
  800ae9:	5d                   	pop    %ebp
  800aea:	c3                   	ret    

00800aeb <strnlen>:

int
strnlen(const char *s, size_t size)
{
  800aeb:	55                   	push   %ebp
  800aec:	89 e5                	mov    %esp,%ebp
  800aee:	53                   	push   %ebx
  800aef:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800af2:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800af5:	85 c9                	test   %ecx,%ecx
  800af7:	74 19                	je     800b12 <strnlen+0x27>
  800af9:	80 3b 00             	cmpb   $0x0,(%ebx)
  800afc:	74 14                	je     800b12 <strnlen+0x27>
  800afe:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
  800b03:	83 c0 01             	add    $0x1,%eax
int
strnlen(const char *s, size_t size)
{
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800b06:	39 c8                	cmp    %ecx,%eax
  800b08:	74 0d                	je     800b17 <strnlen+0x2c>
  800b0a:	80 3c 03 00          	cmpb   $0x0,(%ebx,%eax,1)
  800b0e:	75 f3                	jne    800b03 <strnlen+0x18>
  800b10:	eb 05                	jmp    800b17 <strnlen+0x2c>
  800b12:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
	return n;
}
  800b17:	5b                   	pop    %ebx
  800b18:	5d                   	pop    %ebp
  800b19:	c3                   	ret    

00800b1a <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  800b1a:	55                   	push   %ebp
  800b1b:	89 e5                	mov    %esp,%ebp
  800b1d:	53                   	push   %ebx
  800b1e:	8b 45 08             	mov    0x8(%ebp),%eax
  800b21:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800b24:	ba 00 00 00 00       	mov    $0x0,%edx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  800b29:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
  800b2d:	88 0c 10             	mov    %cl,(%eax,%edx,1)
  800b30:	83 c2 01             	add    $0x1,%edx
  800b33:	84 c9                	test   %cl,%cl
  800b35:	75 f2                	jne    800b29 <strcpy+0xf>
		/* do nothing */;
	return ret;
}
  800b37:	5b                   	pop    %ebx
  800b38:	5d                   	pop    %ebp
  800b39:	c3                   	ret    

00800b3a <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  800b3a:	55                   	push   %ebp
  800b3b:	89 e5                	mov    %esp,%ebp
  800b3d:	56                   	push   %esi
  800b3e:	53                   	push   %ebx
  800b3f:	8b 45 08             	mov    0x8(%ebp),%eax
  800b42:	8b 55 0c             	mov    0xc(%ebp),%edx
  800b45:	8b 75 10             	mov    0x10(%ebp),%esi
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800b48:	85 f6                	test   %esi,%esi
  800b4a:	74 18                	je     800b64 <strncpy+0x2a>
  800b4c:	b9 00 00 00 00       	mov    $0x0,%ecx
		*dst++ = *src;
  800b51:	0f b6 1a             	movzbl (%edx),%ebx
  800b54:	88 1c 08             	mov    %bl,(%eax,%ecx,1)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  800b57:	80 3a 01             	cmpb   $0x1,(%edx)
  800b5a:	83 da ff             	sbb    $0xffffffff,%edx
strncpy(char *dst, const char *src, size_t size) {
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800b5d:	83 c1 01             	add    $0x1,%ecx
  800b60:	39 ce                	cmp    %ecx,%esi
  800b62:	77 ed                	ja     800b51 <strncpy+0x17>
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
	}
	return ret;
}
  800b64:	5b                   	pop    %ebx
  800b65:	5e                   	pop    %esi
  800b66:	5d                   	pop    %ebp
  800b67:	c3                   	ret    

00800b68 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  800b68:	55                   	push   %ebp
  800b69:	89 e5                	mov    %esp,%ebp
  800b6b:	56                   	push   %esi
  800b6c:	53                   	push   %ebx
  800b6d:	8b 75 08             	mov    0x8(%ebp),%esi
  800b70:	8b 55 0c             	mov    0xc(%ebp),%edx
  800b73:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  800b76:	89 f0                	mov    %esi,%eax
  800b78:	85 c9                	test   %ecx,%ecx
  800b7a:	74 27                	je     800ba3 <strlcpy+0x3b>
		while (--size > 0 && *src != '\0')
  800b7c:	83 e9 01             	sub    $0x1,%ecx
  800b7f:	74 1d                	je     800b9e <strlcpy+0x36>
  800b81:	0f b6 1a             	movzbl (%edx),%ebx
  800b84:	84 db                	test   %bl,%bl
  800b86:	74 16                	je     800b9e <strlcpy+0x36>
			*dst++ = *src++;
  800b88:	88 18                	mov    %bl,(%eax)
  800b8a:	83 c0 01             	add    $0x1,%eax
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800b8d:	83 e9 01             	sub    $0x1,%ecx
  800b90:	74 0e                	je     800ba0 <strlcpy+0x38>
			*dst++ = *src++;
  800b92:	83 c2 01             	add    $0x1,%edx
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800b95:	0f b6 1a             	movzbl (%edx),%ebx
  800b98:	84 db                	test   %bl,%bl
  800b9a:	75 ec                	jne    800b88 <strlcpy+0x20>
  800b9c:	eb 02                	jmp    800ba0 <strlcpy+0x38>
  800b9e:	89 f0                	mov    %esi,%eax
			*dst++ = *src++;
		*dst = '\0';
  800ba0:	c6 00 00             	movb   $0x0,(%eax)
  800ba3:	29 f0                	sub    %esi,%eax
	}
	return dst - dst_in;
}
  800ba5:	5b                   	pop    %ebx
  800ba6:	5e                   	pop    %esi
  800ba7:	5d                   	pop    %ebp
  800ba8:	c3                   	ret    

00800ba9 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  800ba9:	55                   	push   %ebp
  800baa:	89 e5                	mov    %esp,%ebp
  800bac:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800baf:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  800bb2:	0f b6 01             	movzbl (%ecx),%eax
  800bb5:	84 c0                	test   %al,%al
  800bb7:	74 15                	je     800bce <strcmp+0x25>
  800bb9:	3a 02                	cmp    (%edx),%al
  800bbb:	75 11                	jne    800bce <strcmp+0x25>
		p++, q++;
  800bbd:	83 c1 01             	add    $0x1,%ecx
  800bc0:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
	while (*p && *p == *q)
  800bc3:	0f b6 01             	movzbl (%ecx),%eax
  800bc6:	84 c0                	test   %al,%al
  800bc8:	74 04                	je     800bce <strcmp+0x25>
  800bca:	3a 02                	cmp    (%edx),%al
  800bcc:	74 ef                	je     800bbd <strcmp+0x14>
  800bce:	0f b6 c0             	movzbl %al,%eax
  800bd1:	0f b6 12             	movzbl (%edx),%edx
  800bd4:	29 d0                	sub    %edx,%eax
		p++, q++;
	return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800bd6:	5d                   	pop    %ebp
  800bd7:	c3                   	ret    

00800bd8 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  800bd8:	55                   	push   %ebp
  800bd9:	89 e5                	mov    %esp,%ebp
  800bdb:	53                   	push   %ebx
  800bdc:	8b 55 08             	mov    0x8(%ebp),%edx
  800bdf:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800be2:	8b 45 10             	mov    0x10(%ebp),%eax
	while (n > 0 && *p && *p == *q)
  800be5:	85 c0                	test   %eax,%eax
  800be7:	74 23                	je     800c0c <strncmp+0x34>
  800be9:	0f b6 1a             	movzbl (%edx),%ebx
  800bec:	84 db                	test   %bl,%bl
  800bee:	74 24                	je     800c14 <strncmp+0x3c>
  800bf0:	3a 19                	cmp    (%ecx),%bl
  800bf2:	75 20                	jne    800c14 <strncmp+0x3c>
  800bf4:	83 e8 01             	sub    $0x1,%eax
  800bf7:	74 13                	je     800c0c <strncmp+0x34>
		n--, p++, q++;
  800bf9:	83 c2 01             	add    $0x1,%edx
  800bfc:	83 c1 01             	add    $0x1,%ecx
}

int
strncmp(const char *p, const char *q, size_t n)
{
	while (n > 0 && *p && *p == *q)
  800bff:	0f b6 1a             	movzbl (%edx),%ebx
  800c02:	84 db                	test   %bl,%bl
  800c04:	74 0e                	je     800c14 <strncmp+0x3c>
  800c06:	3a 19                	cmp    (%ecx),%bl
  800c08:	74 ea                	je     800bf4 <strncmp+0x1c>
  800c0a:	eb 08                	jmp    800c14 <strncmp+0x3c>
  800c0c:	b8 00 00 00 00       	mov    $0x0,%eax
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800c11:	5b                   	pop    %ebx
  800c12:	5d                   	pop    %ebp
  800c13:	c3                   	ret    
	while (n > 0 && *p && *p == *q)
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  800c14:	0f b6 02             	movzbl (%edx),%eax
  800c17:	0f b6 11             	movzbl (%ecx),%edx
  800c1a:	29 d0                	sub    %edx,%eax
  800c1c:	eb f3                	jmp    800c11 <strncmp+0x39>

00800c1e <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  800c1e:	55                   	push   %ebp
  800c1f:	89 e5                	mov    %esp,%ebp
  800c21:	8b 45 08             	mov    0x8(%ebp),%eax
  800c24:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800c28:	0f b6 10             	movzbl (%eax),%edx
  800c2b:	84 d2                	test   %dl,%dl
  800c2d:	74 15                	je     800c44 <strchr+0x26>
		if (*s == c)
  800c2f:	38 ca                	cmp    %cl,%dl
  800c31:	75 07                	jne    800c3a <strchr+0x1c>
  800c33:	eb 14                	jmp    800c49 <strchr+0x2b>
  800c35:	38 ca                	cmp    %cl,%dl
  800c37:	90                   	nop
  800c38:	74 0f                	je     800c49 <strchr+0x2b>
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
	for (; *s; s++)
  800c3a:	83 c0 01             	add    $0x1,%eax
  800c3d:	0f b6 10             	movzbl (%eax),%edx
  800c40:	84 d2                	test   %dl,%dl
  800c42:	75 f1                	jne    800c35 <strchr+0x17>
  800c44:	b8 00 00 00 00       	mov    $0x0,%eax
		if (*s == c)
			return (char *) s;
	return 0;
}
  800c49:	5d                   	pop    %ebp
  800c4a:	c3                   	ret    

00800c4b <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  800c4b:	55                   	push   %ebp
  800c4c:	89 e5                	mov    %esp,%ebp
  800c4e:	8b 45 08             	mov    0x8(%ebp),%eax
  800c51:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800c55:	0f b6 10             	movzbl (%eax),%edx
  800c58:	84 d2                	test   %dl,%dl
  800c5a:	74 18                	je     800c74 <strfind+0x29>
		if (*s == c)
  800c5c:	38 ca                	cmp    %cl,%dl
  800c5e:	75 0a                	jne    800c6a <strfind+0x1f>
  800c60:	eb 12                	jmp    800c74 <strfind+0x29>
  800c62:	38 ca                	cmp    %cl,%dl
  800c64:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  800c68:	74 0a                	je     800c74 <strfind+0x29>
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
	for (; *s; s++)
  800c6a:	83 c0 01             	add    $0x1,%eax
  800c6d:	0f b6 10             	movzbl (%eax),%edx
  800c70:	84 d2                	test   %dl,%dl
  800c72:	75 ee                	jne    800c62 <strfind+0x17>
		if (*s == c)
			break;
	return (char *) s;
}
  800c74:	5d                   	pop    %ebp
  800c75:	c3                   	ret    

00800c76 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  800c76:	55                   	push   %ebp
  800c77:	89 e5                	mov    %esp,%ebp
  800c79:	83 ec 0c             	sub    $0xc,%esp
  800c7c:	89 1c 24             	mov    %ebx,(%esp)
  800c7f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800c83:	89 7c 24 08          	mov    %edi,0x8(%esp)
  800c87:	8b 7d 08             	mov    0x8(%ebp),%edi
  800c8a:	8b 45 0c             	mov    0xc(%ebp),%eax
  800c8d:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800c90:	85 c9                	test   %ecx,%ecx
  800c92:	74 30                	je     800cc4 <memset+0x4e>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800c94:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800c9a:	75 25                	jne    800cc1 <memset+0x4b>
  800c9c:	f6 c1 03             	test   $0x3,%cl
  800c9f:	75 20                	jne    800cc1 <memset+0x4b>
		c &= 0xFF;
  800ca1:	0f b6 d0             	movzbl %al,%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800ca4:	89 d3                	mov    %edx,%ebx
  800ca6:	c1 e3 08             	shl    $0x8,%ebx
  800ca9:	89 d6                	mov    %edx,%esi
  800cab:	c1 e6 18             	shl    $0x18,%esi
  800cae:	89 d0                	mov    %edx,%eax
  800cb0:	c1 e0 10             	shl    $0x10,%eax
  800cb3:	09 f0                	or     %esi,%eax
  800cb5:	09 d0                	or     %edx,%eax
		asm volatile("cld; rep stosl\n"
  800cb7:	09 d8                	or     %ebx,%eax
  800cb9:	c1 e9 02             	shr    $0x2,%ecx
  800cbc:	fc                   	cld    
  800cbd:	f3 ab                	rep stos %eax,%es:(%edi)
{
	char *p;

	if (n == 0)
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800cbf:	eb 03                	jmp    800cc4 <memset+0x4e>
		c = (c<<24)|(c<<16)|(c<<8)|c;
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800cc1:	fc                   	cld    
  800cc2:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800cc4:	89 f8                	mov    %edi,%eax
  800cc6:	8b 1c 24             	mov    (%esp),%ebx
  800cc9:	8b 74 24 04          	mov    0x4(%esp),%esi
  800ccd:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800cd1:	89 ec                	mov    %ebp,%esp
  800cd3:	5d                   	pop    %ebp
  800cd4:	c3                   	ret    

00800cd5 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800cd5:	55                   	push   %ebp
  800cd6:	89 e5                	mov    %esp,%ebp
  800cd8:	83 ec 08             	sub    $0x8,%esp
  800cdb:	89 34 24             	mov    %esi,(%esp)
  800cde:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800ce2:	8b 45 08             	mov    0x8(%ebp),%eax
  800ce5:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;
	
	s = src;
  800ce8:	8b 75 0c             	mov    0xc(%ebp),%esi
	d = dst;
  800ceb:	89 c7                	mov    %eax,%edi
	if (s < d && s + n > d) {
  800ced:	39 c6                	cmp    %eax,%esi
  800cef:	73 35                	jae    800d26 <memmove+0x51>
  800cf1:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  800cf4:	39 d0                	cmp    %edx,%eax
  800cf6:	73 2e                	jae    800d26 <memmove+0x51>
		s += n;
		d += n;
  800cf8:	01 cf                	add    %ecx,%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800cfa:	f6 c2 03             	test   $0x3,%dl
  800cfd:	75 1b                	jne    800d1a <memmove+0x45>
  800cff:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800d05:	75 13                	jne    800d1a <memmove+0x45>
  800d07:	f6 c1 03             	test   $0x3,%cl
  800d0a:	75 0e                	jne    800d1a <memmove+0x45>
			asm volatile("std; rep movsl\n"
  800d0c:	83 ef 04             	sub    $0x4,%edi
  800d0f:	8d 72 fc             	lea    -0x4(%edx),%esi
  800d12:	c1 e9 02             	shr    $0x2,%ecx
  800d15:	fd                   	std    
  800d16:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	s = src;
	d = dst;
	if (s < d && s + n > d) {
		s += n;
		d += n;
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800d18:	eb 09                	jmp    800d23 <memmove+0x4e>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
		else
			asm volatile("std; rep movsb\n"
  800d1a:	83 ef 01             	sub    $0x1,%edi
  800d1d:	8d 72 ff             	lea    -0x1(%edx),%esi
  800d20:	fd                   	std    
  800d21:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  800d23:	fc                   	cld    
	const char *s;
	char *d;
	
	s = src;
	d = dst;
	if (s < d && s + n > d) {
  800d24:	eb 20                	jmp    800d46 <memmove+0x71>
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800d26:	f7 c6 03 00 00 00    	test   $0x3,%esi
  800d2c:	75 15                	jne    800d43 <memmove+0x6e>
  800d2e:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800d34:	75 0d                	jne    800d43 <memmove+0x6e>
  800d36:	f6 c1 03             	test   $0x3,%cl
  800d39:	75 08                	jne    800d43 <memmove+0x6e>
			asm volatile("cld; rep movsl\n"
  800d3b:	c1 e9 02             	shr    $0x2,%ecx
  800d3e:	fc                   	cld    
  800d3f:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800d41:	eb 03                	jmp    800d46 <memmove+0x71>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
		else
			asm volatile("cld; rep movsb\n"
  800d43:	fc                   	cld    
  800d44:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  800d46:	8b 34 24             	mov    (%esp),%esi
  800d49:	8b 7c 24 04          	mov    0x4(%esp),%edi
  800d4d:	89 ec                	mov    %ebp,%esp
  800d4f:	5d                   	pop    %ebp
  800d50:	c3                   	ret    

00800d51 <memcpy>:

/* sigh - gcc emits references to this for structure assignments! */
/* it is *not* prototyped in inc/string.h - do not use directly. */
void *
memcpy(void *dst, void *src, size_t n)
{
  800d51:	55                   	push   %ebp
  800d52:	89 e5                	mov    %esp,%ebp
  800d54:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  800d57:	8b 45 10             	mov    0x10(%ebp),%eax
  800d5a:	89 44 24 08          	mov    %eax,0x8(%esp)
  800d5e:	8b 45 0c             	mov    0xc(%ebp),%eax
  800d61:	89 44 24 04          	mov    %eax,0x4(%esp)
  800d65:	8b 45 08             	mov    0x8(%ebp),%eax
  800d68:	89 04 24             	mov    %eax,(%esp)
  800d6b:	e8 65 ff ff ff       	call   800cd5 <memmove>
}
  800d70:	c9                   	leave  
  800d71:	c3                   	ret    

00800d72 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  800d72:	55                   	push   %ebp
  800d73:	89 e5                	mov    %esp,%ebp
  800d75:	57                   	push   %edi
  800d76:	56                   	push   %esi
  800d77:	53                   	push   %ebx
  800d78:	8b 75 08             	mov    0x8(%ebp),%esi
  800d7b:	8b 7d 0c             	mov    0xc(%ebp),%edi
  800d7e:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800d81:	85 c9                	test   %ecx,%ecx
  800d83:	74 36                	je     800dbb <memcmp+0x49>
		if (*s1 != *s2)
  800d85:	0f b6 06             	movzbl (%esi),%eax
  800d88:	0f b6 1f             	movzbl (%edi),%ebx
  800d8b:	38 d8                	cmp    %bl,%al
  800d8d:	74 20                	je     800daf <memcmp+0x3d>
  800d8f:	eb 14                	jmp    800da5 <memcmp+0x33>
  800d91:	0f b6 44 16 01       	movzbl 0x1(%esi,%edx,1),%eax
  800d96:	0f b6 5c 17 01       	movzbl 0x1(%edi,%edx,1),%ebx
  800d9b:	83 c2 01             	add    $0x1,%edx
  800d9e:	83 e9 01             	sub    $0x1,%ecx
  800da1:	38 d8                	cmp    %bl,%al
  800da3:	74 12                	je     800db7 <memcmp+0x45>
			return (int) *s1 - (int) *s2;
  800da5:	0f b6 c0             	movzbl %al,%eax
  800da8:	0f b6 db             	movzbl %bl,%ebx
  800dab:	29 d8                	sub    %ebx,%eax
  800dad:	eb 11                	jmp    800dc0 <memcmp+0x4e>
memcmp(const void *v1, const void *v2, size_t n)
{
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800daf:	83 e9 01             	sub    $0x1,%ecx
  800db2:	ba 00 00 00 00       	mov    $0x0,%edx
  800db7:	85 c9                	test   %ecx,%ecx
  800db9:	75 d6                	jne    800d91 <memcmp+0x1f>
  800dbb:	b8 00 00 00 00       	mov    $0x0,%eax
			return (int) *s1 - (int) *s2;
		s1++, s2++;
	}

	return 0;
}
  800dc0:	5b                   	pop    %ebx
  800dc1:	5e                   	pop    %esi
  800dc2:	5f                   	pop    %edi
  800dc3:	5d                   	pop    %ebp
  800dc4:	c3                   	ret    

00800dc5 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  800dc5:	55                   	push   %ebp
  800dc6:	89 e5                	mov    %esp,%ebp
  800dc8:	8b 45 08             	mov    0x8(%ebp),%eax
	const void *ends = (const char *) s + n;
  800dcb:	89 c2                	mov    %eax,%edx
  800dcd:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  800dd0:	39 d0                	cmp    %edx,%eax
  800dd2:	73 15                	jae    800de9 <memfind+0x24>
		if (*(const unsigned char *) s == (unsigned char) c)
  800dd4:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  800dd8:	38 08                	cmp    %cl,(%eax)
  800dda:	75 06                	jne    800de2 <memfind+0x1d>
  800ddc:	eb 0b                	jmp    800de9 <memfind+0x24>
  800dde:	38 08                	cmp    %cl,(%eax)
  800de0:	74 07                	je     800de9 <memfind+0x24>

void *
memfind(const void *s, int c, size_t n)
{
	const void *ends = (const char *) s + n;
	for (; s < ends; s++)
  800de2:	83 c0 01             	add    $0x1,%eax
  800de5:	39 c2                	cmp    %eax,%edx
  800de7:	77 f5                	ja     800dde <memfind+0x19>
		if (*(const unsigned char *) s == (unsigned char) c)
			break;
	return (void *) s;
}
  800de9:	5d                   	pop    %ebp
  800dea:	c3                   	ret    

00800deb <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  800deb:	55                   	push   %ebp
  800dec:	89 e5                	mov    %esp,%ebp
  800dee:	57                   	push   %edi
  800def:	56                   	push   %esi
  800df0:	53                   	push   %ebx
  800df1:	83 ec 04             	sub    $0x4,%esp
  800df4:	8b 55 08             	mov    0x8(%ebp),%edx
  800df7:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800dfa:	0f b6 02             	movzbl (%edx),%eax
  800dfd:	3c 20                	cmp    $0x20,%al
  800dff:	74 04                	je     800e05 <strtol+0x1a>
  800e01:	3c 09                	cmp    $0x9,%al
  800e03:	75 0e                	jne    800e13 <strtol+0x28>
		s++;
  800e05:	83 c2 01             	add    $0x1,%edx
{
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800e08:	0f b6 02             	movzbl (%edx),%eax
  800e0b:	3c 20                	cmp    $0x20,%al
  800e0d:	74 f6                	je     800e05 <strtol+0x1a>
  800e0f:	3c 09                	cmp    $0x9,%al
  800e11:	74 f2                	je     800e05 <strtol+0x1a>
		s++;

	// plus/minus sign
	if (*s == '+')
  800e13:	3c 2b                	cmp    $0x2b,%al
  800e15:	75 0c                	jne    800e23 <strtol+0x38>
		s++;
  800e17:	83 c2 01             	add    $0x1,%edx
  800e1a:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800e21:	eb 15                	jmp    800e38 <strtol+0x4d>
	else if (*s == '-')
  800e23:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800e2a:	3c 2d                	cmp    $0x2d,%al
  800e2c:	75 0a                	jne    800e38 <strtol+0x4d>
		s++, neg = 1;
  800e2e:	83 c2 01             	add    $0x1,%edx
  800e31:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800e38:	85 db                	test   %ebx,%ebx
  800e3a:	0f 94 c0             	sete   %al
  800e3d:	74 05                	je     800e44 <strtol+0x59>
  800e3f:	83 fb 10             	cmp    $0x10,%ebx
  800e42:	75 18                	jne    800e5c <strtol+0x71>
  800e44:	80 3a 30             	cmpb   $0x30,(%edx)
  800e47:	75 13                	jne    800e5c <strtol+0x71>
  800e49:	80 7a 01 78          	cmpb   $0x78,0x1(%edx)
  800e4d:	8d 76 00             	lea    0x0(%esi),%esi
  800e50:	75 0a                	jne    800e5c <strtol+0x71>
		s += 2, base = 16;
  800e52:	83 c2 02             	add    $0x2,%edx
  800e55:	bb 10 00 00 00       	mov    $0x10,%ebx
		s++;
	else if (*s == '-')
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800e5a:	eb 15                	jmp    800e71 <strtol+0x86>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800e5c:	84 c0                	test   %al,%al
  800e5e:	66 90                	xchg   %ax,%ax
  800e60:	74 0f                	je     800e71 <strtol+0x86>
  800e62:	bb 0a 00 00 00       	mov    $0xa,%ebx
  800e67:	80 3a 30             	cmpb   $0x30,(%edx)
  800e6a:	75 05                	jne    800e71 <strtol+0x86>
		s++, base = 8;
  800e6c:	83 c2 01             	add    $0x1,%edx
  800e6f:	b3 08                	mov    $0x8,%bl
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800e71:	b8 00 00 00 00       	mov    $0x0,%eax
  800e76:	89 de                	mov    %ebx,%esi

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
  800e78:	0f b6 0a             	movzbl (%edx),%ecx
  800e7b:	89 cf                	mov    %ecx,%edi
  800e7d:	8d 59 d0             	lea    -0x30(%ecx),%ebx
  800e80:	80 fb 09             	cmp    $0x9,%bl
  800e83:	77 08                	ja     800e8d <strtol+0xa2>
			dig = *s - '0';
  800e85:	0f be c9             	movsbl %cl,%ecx
  800e88:	83 e9 30             	sub    $0x30,%ecx
  800e8b:	eb 1e                	jmp    800eab <strtol+0xc0>
		else if (*s >= 'a' && *s <= 'z')
  800e8d:	8d 5f 9f             	lea    -0x61(%edi),%ebx
  800e90:	80 fb 19             	cmp    $0x19,%bl
  800e93:	77 08                	ja     800e9d <strtol+0xb2>
			dig = *s - 'a' + 10;
  800e95:	0f be c9             	movsbl %cl,%ecx
  800e98:	83 e9 57             	sub    $0x57,%ecx
  800e9b:	eb 0e                	jmp    800eab <strtol+0xc0>
		else if (*s >= 'A' && *s <= 'Z')
  800e9d:	8d 5f bf             	lea    -0x41(%edi),%ebx
  800ea0:	80 fb 19             	cmp    $0x19,%bl
  800ea3:	77 15                	ja     800eba <strtol+0xcf>
			dig = *s - 'A' + 10;
  800ea5:	0f be c9             	movsbl %cl,%ecx
  800ea8:	83 e9 37             	sub    $0x37,%ecx
		else
			break;
		if (dig >= base)
  800eab:	39 f1                	cmp    %esi,%ecx
  800ead:	7d 0b                	jge    800eba <strtol+0xcf>
			break;
		s++, val = (val * base) + dig;
  800eaf:	83 c2 01             	add    $0x1,%edx
  800eb2:	0f af c6             	imul   %esi,%eax
  800eb5:	8d 04 01             	lea    (%ecx,%eax,1),%eax
		// we don't properly detect overflow!
	}
  800eb8:	eb be                	jmp    800e78 <strtol+0x8d>
  800eba:	89 c1                	mov    %eax,%ecx

	if (endptr)
  800ebc:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  800ec0:	74 05                	je     800ec7 <strtol+0xdc>
		*endptr = (char *) s;
  800ec2:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800ec5:	89 13                	mov    %edx,(%ebx)
	return (neg ? -val : val);
  800ec7:	89 ca                	mov    %ecx,%edx
  800ec9:	f7 da                	neg    %edx
  800ecb:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  800ecf:	0f 45 c2             	cmovne %edx,%eax
}
  800ed2:	83 c4 04             	add    $0x4,%esp
  800ed5:	5b                   	pop    %ebx
  800ed6:	5e                   	pop    %esi
  800ed7:	5f                   	pop    %edi
  800ed8:	5d                   	pop    %ebp
  800ed9:	c3                   	ret    
	...

00800edc <sys_cgetc>:
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}

int
sys_cgetc(void)
{
  800edc:	55                   	push   %ebp
  800edd:	89 e5                	mov    %esp,%ebp
  800edf:	83 ec 0c             	sub    $0xc,%esp
  800ee2:	89 1c 24             	mov    %ebx,(%esp)
  800ee5:	89 74 24 04          	mov    %esi,0x4(%esp)
  800ee9:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800eed:	ba 00 00 00 00       	mov    $0x0,%edx
  800ef2:	b8 01 00 00 00       	mov    $0x1,%eax
  800ef7:	89 d1                	mov    %edx,%ecx
  800ef9:	89 d3                	mov    %edx,%ebx
  800efb:	89 d7                	mov    %edx,%edi
  800efd:	89 d6                	mov    %edx,%esi
  800eff:	cd 30                	int    $0x30

int
sys_cgetc(void)
{
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  800f01:	8b 1c 24             	mov    (%esp),%ebx
  800f04:	8b 74 24 04          	mov    0x4(%esp),%esi
  800f08:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800f0c:	89 ec                	mov    %ebp,%esp
  800f0e:	5d                   	pop    %ebp
  800f0f:	c3                   	ret    

00800f10 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  800f10:	55                   	push   %ebp
  800f11:	89 e5                	mov    %esp,%ebp
  800f13:	83 ec 0c             	sub    $0xc,%esp
  800f16:	89 1c 24             	mov    %ebx,(%esp)
  800f19:	89 74 24 04          	mov    %esi,0x4(%esp)
  800f1d:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800f21:	b8 00 00 00 00       	mov    $0x0,%eax
  800f26:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f29:	8b 55 08             	mov    0x8(%ebp),%edx
  800f2c:	89 c3                	mov    %eax,%ebx
  800f2e:	89 c7                	mov    %eax,%edi
  800f30:	89 c6                	mov    %eax,%esi
  800f32:	cd 30                	int    $0x30

void
sys_cputs(const char *s, size_t len)
{
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  800f34:	8b 1c 24             	mov    (%esp),%ebx
  800f37:	8b 74 24 04          	mov    0x4(%esp),%esi
  800f3b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800f3f:	89 ec                	mov    %ebp,%esp
  800f41:	5d                   	pop    %ebp
  800f42:	c3                   	ret    

00800f43 <sys_ns_recv>:
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}

int
sys_ns_recv(void *pkt, uint32_t len)
{
  800f43:	55                   	push   %ebp
  800f44:	89 e5                	mov    %esp,%ebp
  800f46:	83 ec 0c             	sub    $0xc,%esp
  800f49:	89 1c 24             	mov    %ebx,(%esp)
  800f4c:	89 74 24 04          	mov    %esi,0x4(%esp)
  800f50:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800f54:	bb 00 00 00 00       	mov    $0x0,%ebx
  800f59:	b8 10 00 00 00       	mov    $0x10,%eax
  800f5e:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f61:	8b 55 08             	mov    0x8(%ebp),%edx
  800f64:	89 df                	mov    %ebx,%edi
  800f66:	89 de                	mov    %ebx,%esi
  800f68:	cd 30                	int    $0x30

int
sys_ns_recv(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_recv, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800f6a:	8b 1c 24             	mov    (%esp),%ebx
  800f6d:	8b 74 24 04          	mov    0x4(%esp),%esi
  800f71:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800f75:	89 ec                	mov    %ebp,%esp
  800f77:	5d                   	pop    %ebp
  800f78:	c3                   	ret    

00800f79 <sys_ns_send>:
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}

int
sys_ns_send(void *pkt, uint32_t len)
{
  800f79:	55                   	push   %ebp
  800f7a:	89 e5                	mov    %esp,%ebp
  800f7c:	83 ec 0c             	sub    $0xc,%esp
  800f7f:	89 1c 24             	mov    %ebx,(%esp)
  800f82:	89 74 24 04          	mov    %esi,0x4(%esp)
  800f86:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800f8a:	bb 00 00 00 00       	mov    $0x0,%ebx
  800f8f:	b8 0f 00 00 00       	mov    $0xf,%eax
  800f94:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f97:	8b 55 08             	mov    0x8(%ebp),%edx
  800f9a:	89 df                	mov    %ebx,%edi
  800f9c:	89 de                	mov    %ebx,%esi
  800f9e:	cd 30                	int    $0x30

int
sys_ns_send(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800fa0:	8b 1c 24             	mov    (%esp),%ebx
  800fa3:	8b 74 24 04          	mov    0x4(%esp),%esi
  800fa7:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800fab:	89 ec                	mov    %ebp,%esp
  800fad:	5d                   	pop    %ebp
  800fae:	c3                   	ret    

00800faf <sys_time_msec>:
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}

unsigned int
sys_time_msec(void)
{
  800faf:	55                   	push   %ebp
  800fb0:	89 e5                	mov    %esp,%ebp
  800fb2:	83 ec 0c             	sub    $0xc,%esp
  800fb5:	89 1c 24             	mov    %ebx,(%esp)
  800fb8:	89 74 24 04          	mov    %esi,0x4(%esp)
  800fbc:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800fc0:	ba 00 00 00 00       	mov    $0x0,%edx
  800fc5:	b8 0e 00 00 00       	mov    $0xe,%eax
  800fca:	89 d1                	mov    %edx,%ecx
  800fcc:	89 d3                	mov    %edx,%ebx
  800fce:	89 d7                	mov    %edx,%edi
  800fd0:	89 d6                	mov    %edx,%esi
  800fd2:	cd 30                	int    $0x30

unsigned int
sys_time_msec(void)
{
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}
  800fd4:	8b 1c 24             	mov    (%esp),%ebx
  800fd7:	8b 74 24 04          	mov    0x4(%esp),%esi
  800fdb:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800fdf:	89 ec                	mov    %ebp,%esp
  800fe1:	5d                   	pop    %ebp
  800fe2:	c3                   	ret    

00800fe3 <sys_ipc_recv>:
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}

int
sys_ipc_recv(void *dstva)
{
  800fe3:	55                   	push   %ebp
  800fe4:	89 e5                	mov    %esp,%ebp
  800fe6:	83 ec 38             	sub    $0x38,%esp
  800fe9:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800fec:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800fef:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800ff2:	b9 00 00 00 00       	mov    $0x0,%ecx
  800ff7:	b8 0d 00 00 00       	mov    $0xd,%eax
  800ffc:	8b 55 08             	mov    0x8(%ebp),%edx
  800fff:	89 cb                	mov    %ecx,%ebx
  801001:	89 cf                	mov    %ecx,%edi
  801003:	89 ce                	mov    %ecx,%esi
  801005:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801007:	85 c0                	test   %eax,%eax
  801009:	7e 28                	jle    801033 <sys_ipc_recv+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  80100b:	89 44 24 10          	mov    %eax,0x10(%esp)
  80100f:	c7 44 24 0c 0d 00 00 	movl   $0xd,0xc(%esp)
  801016:	00 
  801017:	c7 44 24 08 4b 34 80 	movl   $0x80344b,0x8(%esp)
  80101e:	00 
  80101f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801026:	00 
  801027:	c7 04 24 68 34 80 00 	movl   $0x803468,(%esp)
  80102e:	e8 51 f3 ff ff       	call   800384 <_panic>

int
sys_ipc_recv(void *dstva)
{
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  801033:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801036:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801039:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80103c:	89 ec                	mov    %ebp,%esp
  80103e:	5d                   	pop    %ebp
  80103f:	c3                   	ret    

00801040 <sys_ipc_try_send>:
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  801040:	55                   	push   %ebp
  801041:	89 e5                	mov    %esp,%ebp
  801043:	83 ec 38             	sub    $0x38,%esp
  801046:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801049:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80104c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80104f:	be 00 00 00 00       	mov    $0x0,%esi
  801054:	b8 0c 00 00 00       	mov    $0xc,%eax
  801059:	8b 7d 14             	mov    0x14(%ebp),%edi
  80105c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  80105f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801062:	8b 55 08             	mov    0x8(%ebp),%edx
  801065:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801067:	85 c0                	test   %eax,%eax
  801069:	7e 28                	jle    801093 <sys_ipc_try_send+0x53>
		panic("syscall %d returned %d (> 0)", num, ret);
  80106b:	89 44 24 10          	mov    %eax,0x10(%esp)
  80106f:	c7 44 24 0c 0c 00 00 	movl   $0xc,0xc(%esp)
  801076:	00 
  801077:	c7 44 24 08 4b 34 80 	movl   $0x80344b,0x8(%esp)
  80107e:	00 
  80107f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801086:	00 
  801087:	c7 04 24 68 34 80 00 	movl   $0x803468,(%esp)
  80108e:	e8 f1 f2 ff ff       	call   800384 <_panic>

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}
  801093:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801096:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801099:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80109c:	89 ec                	mov    %ebp,%esp
  80109e:	5d                   	pop    %ebp
  80109f:	c3                   	ret    

008010a0 <sys_env_set_pgfault_upcall>:
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  8010a0:	55                   	push   %ebp
  8010a1:	89 e5                	mov    %esp,%ebp
  8010a3:	83 ec 38             	sub    $0x38,%esp
  8010a6:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8010a9:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8010ac:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8010af:	bb 00 00 00 00       	mov    $0x0,%ebx
  8010b4:	b8 0a 00 00 00       	mov    $0xa,%eax
  8010b9:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8010bc:	8b 55 08             	mov    0x8(%ebp),%edx
  8010bf:	89 df                	mov    %ebx,%edi
  8010c1:	89 de                	mov    %ebx,%esi
  8010c3:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8010c5:	85 c0                	test   %eax,%eax
  8010c7:	7e 28                	jle    8010f1 <sys_env_set_pgfault_upcall+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8010c9:	89 44 24 10          	mov    %eax,0x10(%esp)
  8010cd:	c7 44 24 0c 0a 00 00 	movl   $0xa,0xc(%esp)
  8010d4:	00 
  8010d5:	c7 44 24 08 4b 34 80 	movl   $0x80344b,0x8(%esp)
  8010dc:	00 
  8010dd:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8010e4:	00 
  8010e5:	c7 04 24 68 34 80 00 	movl   $0x803468,(%esp)
  8010ec:	e8 93 f2 ff ff       	call   800384 <_panic>

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  8010f1:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8010f4:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8010f7:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8010fa:	89 ec                	mov    %ebp,%esp
  8010fc:	5d                   	pop    %ebp
  8010fd:	c3                   	ret    

008010fe <sys_env_set_trapframe>:
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  8010fe:	55                   	push   %ebp
  8010ff:	89 e5                	mov    %esp,%ebp
  801101:	83 ec 38             	sub    $0x38,%esp
  801104:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801107:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80110a:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80110d:	bb 00 00 00 00       	mov    $0x0,%ebx
  801112:	b8 09 00 00 00       	mov    $0x9,%eax
  801117:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80111a:	8b 55 08             	mov    0x8(%ebp),%edx
  80111d:	89 df                	mov    %ebx,%edi
  80111f:	89 de                	mov    %ebx,%esi
  801121:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801123:	85 c0                	test   %eax,%eax
  801125:	7e 28                	jle    80114f <sys_env_set_trapframe+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801127:	89 44 24 10          	mov    %eax,0x10(%esp)
  80112b:	c7 44 24 0c 09 00 00 	movl   $0x9,0xc(%esp)
  801132:	00 
  801133:	c7 44 24 08 4b 34 80 	movl   $0x80344b,0x8(%esp)
  80113a:	00 
  80113b:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801142:	00 
  801143:	c7 04 24 68 34 80 00 	movl   $0x803468,(%esp)
  80114a:	e8 35 f2 ff ff       	call   800384 <_panic>

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  80114f:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801152:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801155:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801158:	89 ec                	mov    %ebp,%esp
  80115a:	5d                   	pop    %ebp
  80115b:	c3                   	ret    

0080115c <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  80115c:	55                   	push   %ebp
  80115d:	89 e5                	mov    %esp,%ebp
  80115f:	83 ec 38             	sub    $0x38,%esp
  801162:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801165:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801168:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80116b:	bb 00 00 00 00       	mov    $0x0,%ebx
  801170:	b8 08 00 00 00       	mov    $0x8,%eax
  801175:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801178:	8b 55 08             	mov    0x8(%ebp),%edx
  80117b:	89 df                	mov    %ebx,%edi
  80117d:	89 de                	mov    %ebx,%esi
  80117f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801181:	85 c0                	test   %eax,%eax
  801183:	7e 28                	jle    8011ad <sys_env_set_status+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801185:	89 44 24 10          	mov    %eax,0x10(%esp)
  801189:	c7 44 24 0c 08 00 00 	movl   $0x8,0xc(%esp)
  801190:	00 
  801191:	c7 44 24 08 4b 34 80 	movl   $0x80344b,0x8(%esp)
  801198:	00 
  801199:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8011a0:	00 
  8011a1:	c7 04 24 68 34 80 00 	movl   $0x803468,(%esp)
  8011a8:	e8 d7 f1 ff ff       	call   800384 <_panic>

int
sys_env_set_status(envid_t envid, int status)
{
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  8011ad:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8011b0:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8011b3:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8011b6:	89 ec                	mov    %ebp,%esp
  8011b8:	5d                   	pop    %ebp
  8011b9:	c3                   	ret    

008011ba <sys_page_unmap>:
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}

int
sys_page_unmap(envid_t envid, void *va)
{
  8011ba:	55                   	push   %ebp
  8011bb:	89 e5                	mov    %esp,%ebp
  8011bd:	83 ec 38             	sub    $0x38,%esp
  8011c0:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8011c3:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8011c6:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8011c9:	bb 00 00 00 00       	mov    $0x0,%ebx
  8011ce:	b8 06 00 00 00       	mov    $0x6,%eax
  8011d3:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8011d6:	8b 55 08             	mov    0x8(%ebp),%edx
  8011d9:	89 df                	mov    %ebx,%edi
  8011db:	89 de                	mov    %ebx,%esi
  8011dd:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8011df:	85 c0                	test   %eax,%eax
  8011e1:	7e 28                	jle    80120b <sys_page_unmap+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8011e3:	89 44 24 10          	mov    %eax,0x10(%esp)
  8011e7:	c7 44 24 0c 06 00 00 	movl   $0x6,0xc(%esp)
  8011ee:	00 
  8011ef:	c7 44 24 08 4b 34 80 	movl   $0x80344b,0x8(%esp)
  8011f6:	00 
  8011f7:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8011fe:	00 
  8011ff:	c7 04 24 68 34 80 00 	movl   $0x803468,(%esp)
  801206:	e8 79 f1 ff ff       	call   800384 <_panic>

int
sys_page_unmap(envid_t envid, void *va)
{
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  80120b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80120e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801211:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801214:	89 ec                	mov    %ebp,%esp
  801216:	5d                   	pop    %ebp
  801217:	c3                   	ret    

00801218 <sys_page_map>:
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  801218:	55                   	push   %ebp
  801219:	89 e5                	mov    %esp,%ebp
  80121b:	83 ec 38             	sub    $0x38,%esp
  80121e:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801221:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801224:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801227:	b8 05 00 00 00       	mov    $0x5,%eax
  80122c:	8b 75 18             	mov    0x18(%ebp),%esi
  80122f:	8b 7d 14             	mov    0x14(%ebp),%edi
  801232:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801235:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801238:	8b 55 08             	mov    0x8(%ebp),%edx
  80123b:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80123d:	85 c0                	test   %eax,%eax
  80123f:	7e 28                	jle    801269 <sys_page_map+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801241:	89 44 24 10          	mov    %eax,0x10(%esp)
  801245:	c7 44 24 0c 05 00 00 	movl   $0x5,0xc(%esp)
  80124c:	00 
  80124d:	c7 44 24 08 4b 34 80 	movl   $0x80344b,0x8(%esp)
  801254:	00 
  801255:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80125c:	00 
  80125d:	c7 04 24 68 34 80 00 	movl   $0x803468,(%esp)
  801264:	e8 1b f1 ff ff       	call   800384 <_panic>

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  801269:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80126c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80126f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801272:	89 ec                	mov    %ebp,%esp
  801274:	5d                   	pop    %ebp
  801275:	c3                   	ret    

00801276 <sys_page_alloc>:
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  801276:	55                   	push   %ebp
  801277:	89 e5                	mov    %esp,%ebp
  801279:	83 ec 38             	sub    $0x38,%esp
  80127c:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  80127f:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801282:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801285:	be 00 00 00 00       	mov    $0x0,%esi
  80128a:	b8 04 00 00 00       	mov    $0x4,%eax
  80128f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801292:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801295:	8b 55 08             	mov    0x8(%ebp),%edx
  801298:	89 f7                	mov    %esi,%edi
  80129a:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80129c:	85 c0                	test   %eax,%eax
  80129e:	7e 28                	jle    8012c8 <sys_page_alloc+0x52>
		panic("syscall %d returned %d (> 0)", num, ret);
  8012a0:	89 44 24 10          	mov    %eax,0x10(%esp)
  8012a4:	c7 44 24 0c 04 00 00 	movl   $0x4,0xc(%esp)
  8012ab:	00 
  8012ac:	c7 44 24 08 4b 34 80 	movl   $0x80344b,0x8(%esp)
  8012b3:	00 
  8012b4:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8012bb:	00 
  8012bc:	c7 04 24 68 34 80 00 	movl   $0x803468,(%esp)
  8012c3:	e8 bc f0 ff ff       	call   800384 <_panic>

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  8012c8:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8012cb:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8012ce:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8012d1:	89 ec                	mov    %ebp,%esp
  8012d3:	5d                   	pop    %ebp
  8012d4:	c3                   	ret    

008012d5 <sys_yield>:
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}

void
sys_yield(void)
{
  8012d5:	55                   	push   %ebp
  8012d6:	89 e5                	mov    %esp,%ebp
  8012d8:	83 ec 0c             	sub    $0xc,%esp
  8012db:	89 1c 24             	mov    %ebx,(%esp)
  8012de:	89 74 24 04          	mov    %esi,0x4(%esp)
  8012e2:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8012e6:	ba 00 00 00 00       	mov    $0x0,%edx
  8012eb:	b8 0b 00 00 00       	mov    $0xb,%eax
  8012f0:	89 d1                	mov    %edx,%ecx
  8012f2:	89 d3                	mov    %edx,%ebx
  8012f4:	89 d7                	mov    %edx,%edi
  8012f6:	89 d6                	mov    %edx,%esi
  8012f8:	cd 30                	int    $0x30

void
sys_yield(void)
{
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  8012fa:	8b 1c 24             	mov    (%esp),%ebx
  8012fd:	8b 74 24 04          	mov    0x4(%esp),%esi
  801301:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801305:	89 ec                	mov    %ebp,%esp
  801307:	5d                   	pop    %ebp
  801308:	c3                   	ret    

00801309 <sys_getenvid>:
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}

envid_t
sys_getenvid(void)
{
  801309:	55                   	push   %ebp
  80130a:	89 e5                	mov    %esp,%ebp
  80130c:	83 ec 0c             	sub    $0xc,%esp
  80130f:	89 1c 24             	mov    %ebx,(%esp)
  801312:	89 74 24 04          	mov    %esi,0x4(%esp)
  801316:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80131a:	ba 00 00 00 00       	mov    $0x0,%edx
  80131f:	b8 02 00 00 00       	mov    $0x2,%eax
  801324:	89 d1                	mov    %edx,%ecx
  801326:	89 d3                	mov    %edx,%ebx
  801328:	89 d7                	mov    %edx,%edi
  80132a:	89 d6                	mov    %edx,%esi
  80132c:	cd 30                	int    $0x30

envid_t
sys_getenvid(void)
{
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  80132e:	8b 1c 24             	mov    (%esp),%ebx
  801331:	8b 74 24 04          	mov    0x4(%esp),%esi
  801335:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801339:	89 ec                	mov    %ebp,%esp
  80133b:	5d                   	pop    %ebp
  80133c:	c3                   	ret    

0080133d <sys_env_destroy>:
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}

int
sys_env_destroy(envid_t envid)
{
  80133d:	55                   	push   %ebp
  80133e:	89 e5                	mov    %esp,%ebp
  801340:	83 ec 38             	sub    $0x38,%esp
  801343:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801346:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801349:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80134c:	b9 00 00 00 00       	mov    $0x0,%ecx
  801351:	b8 03 00 00 00       	mov    $0x3,%eax
  801356:	8b 55 08             	mov    0x8(%ebp),%edx
  801359:	89 cb                	mov    %ecx,%ebx
  80135b:	89 cf                	mov    %ecx,%edi
  80135d:	89 ce                	mov    %ecx,%esi
  80135f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801361:	85 c0                	test   %eax,%eax
  801363:	7e 28                	jle    80138d <sys_env_destroy+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  801365:	89 44 24 10          	mov    %eax,0x10(%esp)
  801369:	c7 44 24 0c 03 00 00 	movl   $0x3,0xc(%esp)
  801370:	00 
  801371:	c7 44 24 08 4b 34 80 	movl   $0x80344b,0x8(%esp)
  801378:	00 
  801379:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801380:	00 
  801381:	c7 04 24 68 34 80 00 	movl   $0x803468,(%esp)
  801388:	e8 f7 ef ff ff       	call   800384 <_panic>

int
sys_env_destroy(envid_t envid)
{
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  80138d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801390:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801393:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801396:	89 ec                	mov    %ebp,%esp
  801398:	5d                   	pop    %ebp
  801399:	c3                   	ret    
  80139a:	00 00                	add    %al,(%eax)
  80139c:	00 00                	add    %al,(%eax)
	...

008013a0 <sfork>:
}

// Challenge!
int
sfork(void)
{
  8013a0:	55                   	push   %ebp
  8013a1:	89 e5                	mov    %esp,%ebp
  8013a3:	83 ec 18             	sub    $0x18,%esp
	panic("sfork not implemented");
  8013a6:	c7 44 24 08 76 34 80 	movl   $0x803476,0x8(%esp)
  8013ad:	00 
  8013ae:	c7 44 24 04 9a 00 00 	movl   $0x9a,0x4(%esp)
  8013b5:	00 
  8013b6:	c7 04 24 8c 34 80 00 	movl   $0x80348c,(%esp)
  8013bd:	e8 c2 ef ff ff       	call   800384 <_panic>

008013c2 <fork>:
//   Neither user exception stack should ever be marked copy-on-write,
//   so you must allocate a new page for the child's user exception stack.
//
envid_t
fork(void)
{
  8013c2:	55                   	push   %ebp
  8013c3:	89 e5                	mov    %esp,%ebp
  8013c5:	57                   	push   %edi
  8013c6:	56                   	push   %esi
  8013c7:	53                   	push   %ebx
  8013c8:	83 ec 3c             	sub    $0x3c,%esp
    int r   = 0;
    int i;
    envid_t childId = 0;
	// LAB 4: Your code here.
    // Setup parent process pgfault handler.
    set_pgfault_handler(pgfault);
  8013cb:	c7 04 24 2c 16 80 00 	movl   $0x80162c,(%esp)
  8013d2:	e8 bd 17 00 00       	call   802b94 <set_pgfault_handler>
static __inline envid_t sys_exofork(void) __attribute__((always_inline));
static __inline envid_t
sys_exofork(void)
{
	envid_t ret;
	__asm __volatile("int %2"
  8013d7:	ba 07 00 00 00       	mov    $0x7,%edx
  8013dc:	89 d0                	mov    %edx,%eax
  8013de:	cd 30                	int    $0x30
  8013e0:	89 45 d8             	mov    %eax,-0x28(%ebp)
    childId=sys_exofork();

    if (childId<0) {
  8013e3:	85 c0                	test   %eax,%eax
  8013e5:	79 20                	jns    801407 <fork+0x45>
        panic("Parent: sys_exofork. Error: 0x%x\n", childId);
  8013e7:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8013eb:	c7 44 24 08 fc 34 80 	movl   $0x8034fc,0x8(%esp)
  8013f2:	00 
  8013f3:	c7 44 24 04 7b 00 00 	movl   $0x7b,0x4(%esp)
  8013fa:	00 
  8013fb:	c7 04 24 8c 34 80 00 	movl   $0x80348c,(%esp)
  801402:	e8 7d ef ff ff       	call   800384 <_panic>
    } else if (childId>0) {
  801407:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  80140b:	0f 8e f3 01 00 00    	jle    801604 <fork+0x242>
      // Setup child process' pgfault handler.
      if ((r=sys_env_set_pgfault_upcall(childId, _pgfault_upcall))) {
  801411:	c7 44 24 04 04 2c 80 	movl   $0x802c04,0x4(%esp)
  801418:	00 
  801419:	8b 45 d8             	mov    -0x28(%ebp),%eax
  80141c:	89 04 24             	mov    %eax,(%esp)
  80141f:	e8 7c fc ff ff       	call   8010a0 <sys_env_set_pgfault_upcall>
  801424:	85 c0                	test   %eax,%eax
  801426:	74 20                	je     801448 <fork+0x86>
          panic("Child: sys_env_set_pgfault_upcall. Error: %d\n", r);
  801428:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80142c:	c7 44 24 08 20 35 80 	movl   $0x803520,0x8(%esp)
  801433:	00 
  801434:	c7 44 24 04 7f 00 00 	movl   $0x7f,0x4(%esp)
  80143b:	00 
  80143c:	c7 04 24 8c 34 80 00 	movl   $0x80348c,(%esp)
  801443:	e8 3c ef ff ff       	call   800384 <_panic>
      }
      
      // Setup child's Image.
      // Allocate page for child's user exception stack.
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
  801448:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  80144f:	00 
  801450:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  801457:	ee 
  801458:	8b 45 d8             	mov    -0x28(%ebp),%eax
  80145b:	89 04 24             	mov    %eax,(%esp)
  80145e:	e8 13 fe ff ff       	call   801276 <sys_page_alloc>
  801463:	85 c0                	test   %eax,%eax
  801465:	79 20                	jns    801487 <fork+0xc5>
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
  801467:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80146b:	c7 44 24 08 50 35 80 	movl   $0x803550,0x8(%esp)
  801472:	00 
  801473:	c7 44 24 04 85 00 00 	movl   $0x85,0x4(%esp)
  80147a:	00 
  80147b:	c7 04 24 8c 34 80 00 	movl   $0x80348c,(%esp)
  801482:	e8 fd ee ff ff       	call   800384 <_panic>
  801487:	be 00 00 80 00       	mov    $0x800000,%esi
  80148c:	bb 00 00 80 00       	mov    $0x800000,%ebx
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
        if (vpd[VPD(i)]&PTE_P)
  801491:	bf 00 d0 7b ef       	mov    $0xef7bd000,%edi
  801496:	89 f0                	mov    %esi,%eax
  801498:	c1 e8 16             	shr    $0x16,%eax
  80149b:	8b 04 87             	mov    (%edi,%eax,4),%eax
  80149e:	a8 01                	test   $0x1,%al
  8014a0:	0f 84 13 01 00 00    	je     8015b9 <fork+0x1f7>
// 
static int
duppage(envid_t envid, unsigned pn)
{
	int r           = 0;
  int perm        = vpt[VPN(pn)]&PTE_USER;
  8014a6:	89 f0                	mov    %esi,%eax
  8014a8:	c1 e8 0c             	shr    $0xc,%eax
  8014ab:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  8014b2:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  8014b5:	25 07 0e 00 00       	and    $0xe07,%eax
  8014ba:	89 45 e0             	mov    %eax,-0x20(%ebp)
  envid_t env_id  = sys_getenvid();
  8014bd:	e8 47 fe ff ff       	call   801309 <sys_getenvid>
  8014c2:	89 45 dc             	mov    %eax,-0x24(%ebp)

	// LAB 4: Your code here.
  if ((perm&PTE_P) && (perm&PTE_W || perm&PTE_COW) && (!(perm&PTE_SHARE))) {
  8014c5:	f6 45 e4 01          	testb  $0x1,-0x1c(%ebp)
  8014c9:	0f 84 ea 00 00 00    	je     8015b9 <fork+0x1f7>
  8014cf:	f7 45 e0 02 08 00 00 	testl  $0x802,-0x20(%ebp)
  8014d6:	0f 84 9d 00 00 00    	je     801579 <fork+0x1b7>
  8014dc:	f7 45 e0 00 04 00 00 	testl  $0x400,-0x20(%ebp)
  8014e3:	0f 85 90 00 00 00    	jne    801579 <fork+0x1b7>
    perm    &= (~PTE_W);
  8014e9:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8014ec:	83 e0 fd             	and    $0xfffffffd,%eax
    perm    |= PTE_COW;
  8014ef:	80 cc 08             	or     $0x8,%ah
  8014f2:	89 45 e4             	mov    %eax,-0x1c(%ebp)
    
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  8014f5:	89 75 e0             	mov    %esi,-0x20(%ebp)
  8014f8:	89 44 24 10          	mov    %eax,0x10(%esp)
  8014fc:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801500:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801503:	89 44 24 08          	mov    %eax,0x8(%esp)
  801507:	89 74 24 04          	mov    %esi,0x4(%esp)
  80150b:	8b 45 dc             	mov    -0x24(%ebp),%eax
  80150e:	89 04 24             	mov    %eax,(%esp)
  801511:	e8 02 fd ff ff       	call   801218 <sys_page_map>
  801516:	85 c0                	test   %eax,%eax
  801518:	79 1b                	jns    801535 <fork+0x173>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  80151a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80151e:	89 74 24 08          	mov    %esi,0x8(%esp)
  801522:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801525:	89 44 24 04          	mov    %eax,0x4(%esp)
  801529:	c7 04 24 78 35 80 00 	movl   $0x803578,(%esp)
  801530:	e8 14 ef ff ff       	call   800449 <cprintf>
    // Map permissions back to parent on COW.
    if ((r=sys_page_map(envid, (void *)pn, env_id, (void *)pn, perm))<0)
  801535:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801538:	89 44 24 10          	mov    %eax,0x10(%esp)
  80153c:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80153f:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801543:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801546:	89 44 24 08          	mov    %eax,0x8(%esp)
  80154a:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80154d:	89 44 24 04          	mov    %eax,0x4(%esp)
  801551:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801554:	89 04 24             	mov    %eax,(%esp)
  801557:	e8 bc fc ff ff       	call   801218 <sys_page_map>
  80155c:	85 c0                	test   %eax,%eax
  80155e:	79 59                	jns    8015b9 <fork+0x1f7>
      cprintf("[0x%x] Mapping to PARENT: sys_page_map. Error: %d\n", env_id, r);
  801560:	89 44 24 08          	mov    %eax,0x8(%esp)
  801564:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801567:	89 44 24 04          	mov    %eax,0x4(%esp)
  80156b:	c7 04 24 b8 35 80 00 	movl   $0x8035b8,(%esp)
  801572:	e8 d2 ee ff ff       	call   800449 <cprintf>
  801577:	eb 40                	jmp    8015b9 <fork+0x1f7>
  } else if (perm&PTE_P){
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  801579:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80157c:	89 44 24 10          	mov    %eax,0x10(%esp)
  801580:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801584:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801587:	89 44 24 08          	mov    %eax,0x8(%esp)
  80158b:	89 74 24 04          	mov    %esi,0x4(%esp)
  80158f:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801592:	89 04 24             	mov    %eax,(%esp)
  801595:	e8 7e fc ff ff       	call   801218 <sys_page_map>
  80159a:	85 c0                	test   %eax,%eax
  80159c:	79 1b                	jns    8015b9 <fork+0x1f7>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  80159e:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8015a2:	89 74 24 08          	mov    %esi,0x8(%esp)
  8015a6:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8015a9:	89 44 24 04          	mov    %eax,0x4(%esp)
  8015ad:	c7 04 24 78 35 80 00 	movl   $0x803578,(%esp)
  8015b4:	e8 90 ee ff ff       	call   800449 <cprintf>
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
  8015b9:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  8015bf:	89 de                	mov    %ebx,%esi
  8015c1:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  8015c7:	0f 85 c9 fe ff ff    	jne    801496 <fork+0xd4>
        if (vpd[VPD(i)]&PTE_P)
          duppage(childId, i);

      // Set child as runnable.
      if ((r = sys_env_set_status(childId, ENV_RUNNABLE)) < 0)
  8015cd:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8015d4:	00 
  8015d5:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8015d8:	89 04 24             	mov    %eax,(%esp)
  8015db:	e8 7c fb ff ff       	call   80115c <sys_env_set_status>
  8015e0:	85 c0                	test   %eax,%eax
  8015e2:	79 3d                	jns    801621 <fork+0x25f>
        panic("Parent: sys_env_set_status: %e\n", r);
  8015e4:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8015e8:	c7 44 24 08 ec 35 80 	movl   $0x8035ec,0x8(%esp)
  8015ef:	00 
  8015f0:	c7 44 24 04 8f 00 00 	movl   $0x8f,0x4(%esp)
  8015f7:	00 
  8015f8:	c7 04 24 8c 34 80 00 	movl   $0x80348c,(%esp)
  8015ff:	e8 80 ed ff ff       	call   800384 <_panic>
    } else if (childId==0) {
  801604:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  801608:	75 17                	jne    801621 <fork+0x25f>
      env = &envs [ENVX(sys_getenvid())];
  80160a:	e8 fa fc ff ff       	call   801309 <sys_getenvid>
  80160f:	25 ff 03 00 00       	and    $0x3ff,%eax
  801614:	6b c0 7c             	imul   $0x7c,%eax,%eax
  801617:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  80161c:	a3 78 70 80 00       	mov    %eax,0x807078
    }
    return childId;
}
  801621:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801624:	83 c4 3c             	add    $0x3c,%esp
  801627:	5b                   	pop    %ebx
  801628:	5e                   	pop    %esi
  801629:	5f                   	pop    %edi
  80162a:	5d                   	pop    %ebp
  80162b:	c3                   	ret    

0080162c <pgfault>:
// Custom page fault handler - if faulting page is copy-on-write,
// map in our own private writable copy.
//
static void
pgfault(struct UTrapframe *utf)
{
  80162c:	55                   	push   %ebp
  80162d:	89 e5                	mov    %esp,%ebp
  80162f:	57                   	push   %edi
  801630:	56                   	push   %esi
  801631:	53                   	push   %ebx
  801632:	83 ec 3c             	sub    $0x3c,%esp
  void *addr    = (void *) utf->utf_fault_va;
  801635:	8b 45 08             	mov    0x8(%ebp),%eax
  801638:	8b 38                	mov    (%eax),%edi
  uint32_t err  = utf->utf_err;
  80163a:	8b 50 04             	mov    0x4(%eax),%edx
  80163d:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  int r         = 0;
  int perm      = 0;
  void *align   = (void *)((int)addr&(~0xFFF));
  801640:	89 fe                	mov    %edi,%esi
  801642:	81 e6 00 f0 ff ff    	and    $0xfffff000,%esi
  envid_t envid = sys_getenvid();
  801648:	e8 bc fc ff ff       	call   801309 <sys_getenvid>
  80164d:	89 c3                	mov    %eax,%ebx
	// copy-on-write page.  If not, panic.
	// Hint:
	//   Use the read-only page table mappings at vpt
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
  80164f:	89 f2                	mov    %esi,%edx
  801651:	89 f0                	mov    %esi,%eax
  801653:	c1 e8 16             	shr    $0x16,%eax
  801656:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  80165d:	a8 01                	test   $0x1,%al
  80165f:	74 3e                	je     80169f <pgfault+0x73>
  801661:	c1 ea 0c             	shr    $0xc,%edx
  801664:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  80166b:	a8 01                	test   $0x1,%al
  80166d:	74 30                	je     80169f <pgfault+0x73>
    perm  = vpt[VPN(addr)]&PTE_USER;
  80166f:	c1 ef 0c             	shr    $0xc,%edi
  801672:	8b 3c bd 00 00 40 ef 	mov    -0x10c00000(,%edi,4),%edi
	// page to the old page's address.
	// Hint:
	//   You should make three system calls.
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  801679:	81 e7 07 06 00 00    	and    $0x607,%edi
  perm    |= PTE_W;
  80167f:	83 cf 02             	or     $0x2,%edi
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
  801682:	89 7c 24 08          	mov    %edi,0x8(%esp)
  801686:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  80168d:	00 
  80168e:	89 1c 24             	mov    %ebx,(%esp)
  801691:	e8 e0 fb ff ff       	call   801276 <sys_page_alloc>
  801696:	85 c0                	test   %eax,%eax
  801698:	74 46                	je     8016e0 <pgfault+0xb4>
  80169a:	e9 cd 00 00 00       	jmp    80176c <pgfault+0x140>
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
    perm  = vpt[VPN(addr)]&PTE_USER;
  else {
    cprintf("Tryig to acess address: %x eip: %x Err: %x\n", align, utf->utf_eip, err);
  80169f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8016a2:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8016a6:	8b 55 08             	mov    0x8(%ebp),%edx
  8016a9:	8b 42 28             	mov    0x28(%edx),%eax
  8016ac:	89 44 24 08          	mov    %eax,0x8(%esp)
  8016b0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8016b4:	c7 04 24 0c 36 80 00 	movl   $0x80360c,(%esp)
  8016bb:	e8 89 ed ff ff       	call   800449 <cprintf>
    panic("Go to hell :[%x]\n", envid);
  8016c0:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8016c4:	c7 44 24 08 97 34 80 	movl   $0x803497,0x8(%esp)
  8016cb:	00 
  8016cc:	c7 44 24 04 24 00 00 	movl   $0x24,0x4(%esp)
  8016d3:	00 
  8016d4:	c7 04 24 8c 34 80 00 	movl   $0x80348c,(%esp)
  8016db:	e8 a4 ec ff ff       	call   800384 <_panic>
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  perm    |= PTE_W;
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
    memmove((void *)PFTEMP, align, PGSIZE);
  8016e0:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
  8016e7:	00 
  8016e8:	89 74 24 04          	mov    %esi,0x4(%esp)
  8016ec:	c7 04 24 00 f0 7f 00 	movl   $0x7ff000,(%esp)
  8016f3:	e8 dd f5 ff ff       	call   800cd5 <memmove>
    if((r=sys_page_map(envid, (void *)PFTEMP, envid, align, perm)))
  8016f8:	89 7c 24 10          	mov    %edi,0x10(%esp)
  8016fc:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801700:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801704:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  80170b:	00 
  80170c:	89 1c 24             	mov    %ebx,(%esp)
  80170f:	e8 04 fb ff ff       	call   801218 <sys_page_map>
  801714:	85 c0                	test   %eax,%eax
  801716:	74 20                	je     801738 <pgfault+0x10c>
      panic("sys_page_map. Error: 0x%x\n", r);
  801718:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80171c:	c7 44 24 08 a9 34 80 	movl   $0x8034a9,0x8(%esp)
  801723:	00 
  801724:	c7 44 24 04 34 00 00 	movl   $0x34,0x4(%esp)
  80172b:	00 
  80172c:	c7 04 24 8c 34 80 00 	movl   $0x80348c,(%esp)
  801733:	e8 4c ec ff ff       	call   800384 <_panic>

    if ((r=sys_page_unmap(envid, (void *)PFTEMP)))
  801738:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  80173f:	00 
  801740:	89 1c 24             	mov    %ebx,(%esp)
  801743:	e8 72 fa ff ff       	call   8011ba <sys_page_unmap>
  801748:	85 c0                	test   %eax,%eax
  80174a:	74 40                	je     80178c <pgfault+0x160>
      panic("sys_page_unmap. Error: 0x%x\n", r);
  80174c:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801750:	c7 44 24 08 c4 34 80 	movl   $0x8034c4,0x8(%esp)
  801757:	00 
  801758:	c7 44 24 04 37 00 00 	movl   $0x37,0x4(%esp)
  80175f:	00 
  801760:	c7 04 24 8c 34 80 00 	movl   $0x80348c,(%esp)
  801767:	e8 18 ec ff ff       	call   800384 <_panic>
  } else
    panic("sys_page_alloc. Error: %d\n", r);
  80176c:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801770:	c7 44 24 08 e1 34 80 	movl   $0x8034e1,0x8(%esp)
  801777:	00 
  801778:	c7 44 24 04 39 00 00 	movl   $0x39,0x4(%esp)
  80177f:	00 
  801780:	c7 04 24 8c 34 80 00 	movl   $0x80348c,(%esp)
  801787:	e8 f8 eb ff ff       	call   800384 <_panic>
}
  80178c:	83 c4 3c             	add    $0x3c,%esp
  80178f:	5b                   	pop    %ebx
  801790:	5e                   	pop    %esi
  801791:	5f                   	pop    %edi
  801792:	5d                   	pop    %ebp
  801793:	c3                   	ret    
	...

008017a0 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  8017a0:	55                   	push   %ebp
  8017a1:	89 e5                	mov    %esp,%ebp
  8017a3:	8b 45 08             	mov    0x8(%ebp),%eax
  8017a6:	05 00 00 00 30       	add    $0x30000000,%eax
  8017ab:	c1 e8 0c             	shr    $0xc,%eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
}
  8017ae:	5d                   	pop    %ebp
  8017af:	c3                   	ret    

008017b0 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  8017b0:	55                   	push   %ebp
  8017b1:	89 e5                	mov    %esp,%ebp
  8017b3:	83 ec 04             	sub    $0x4,%esp
	return INDEX2DATA(fd2num(fd));
  8017b6:	8b 45 08             	mov    0x8(%ebp),%eax
  8017b9:	89 04 24             	mov    %eax,(%esp)
  8017bc:	e8 df ff ff ff       	call   8017a0 <fd2num>
  8017c1:	05 20 00 0d 00       	add    $0xd0020,%eax
  8017c6:	c1 e0 0c             	shl    $0xc,%eax
}
  8017c9:	c9                   	leave  
  8017ca:	c3                   	ret    

008017cb <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  8017cb:	55                   	push   %ebp
  8017cc:	89 e5                	mov    %esp,%ebp
  8017ce:	57                   	push   %edi
  8017cf:	56                   	push   %esi
  8017d0:	53                   	push   %ebx
  8017d1:	8b 7d 08             	mov    0x8(%ebp),%edi
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
  8017d4:	a1 00 dd 7b ef       	mov    0xef7bdd00,%eax
  8017d9:	a8 01                	test   $0x1,%al
  8017db:	74 36                	je     801813 <fd_alloc+0x48>
  8017dd:	a1 00 00 74 ef       	mov    0xef740000,%eax
  8017e2:	a8 01                	test   $0x1,%al
  8017e4:	74 2d                	je     801813 <fd_alloc+0x48>
  8017e6:	b8 00 10 00 d0       	mov    $0xd0001000,%eax
  8017eb:	b9 00 d0 7b ef       	mov    $0xef7bd000,%ecx
  8017f0:	be 00 00 40 ef       	mov    $0xef400000,%esi
  8017f5:	89 c3                	mov    %eax,%ebx
  8017f7:	89 c2                	mov    %eax,%edx
  8017f9:	c1 ea 16             	shr    $0x16,%edx
  8017fc:	8b 14 91             	mov    (%ecx,%edx,4),%edx
  8017ff:	f6 c2 01             	test   $0x1,%dl
  801802:	74 14                	je     801818 <fd_alloc+0x4d>
  801804:	89 c2                	mov    %eax,%edx
  801806:	c1 ea 0c             	shr    $0xc,%edx
  801809:	8b 14 96             	mov    (%esi,%edx,4),%edx
  80180c:	f6 c2 01             	test   $0x1,%dl
  80180f:	75 10                	jne    801821 <fd_alloc+0x56>
  801811:	eb 05                	jmp    801818 <fd_alloc+0x4d>
  801813:	bb 00 00 00 d0       	mov    $0xd0000000,%ebx
			*fd_store = fd;
  801818:	89 1f                	mov    %ebx,(%edi)
  80181a:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  80181f:	eb 17                	jmp    801838 <fd_alloc+0x6d>
  801821:	05 00 10 00 00       	add    $0x1000,%eax
fd_alloc(struct Fd **fd_store)
{
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
  801826:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  80182b:	75 c8                	jne    8017f5 <fd_alloc+0x2a>
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  80182d:	c7 07 00 00 00 00    	movl   $0x0,(%edi)
  801833:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
	return -E_MAX_OPEN;
}
  801838:	5b                   	pop    %ebx
  801839:	5e                   	pop    %esi
  80183a:	5f                   	pop    %edi
  80183b:	5d                   	pop    %ebp
  80183c:	c3                   	ret    

0080183d <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  80183d:	55                   	push   %ebp
  80183e:	89 e5                	mov    %esp,%ebp
	struct Fd *fd=NULL;

	if (fdnum < 0 || fdnum >= MAXFD) {
  801840:	8b 45 08             	mov    0x8(%ebp),%eax
  801843:	83 f8 1f             	cmp    $0x1f,%eax
  801846:	77 36                	ja     80187e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] bad fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  801848:	05 00 00 0d 00       	add    $0xd0000,%eax
  80184d:	c1 e0 0c             	shl    $0xc,%eax
	if (!(vpd[PDX(fd)] & PTE_P) || !(vpt[VPN(fd)] & PTE_P)) {
  801850:	89 c2                	mov    %eax,%edx
  801852:	c1 ea 16             	shr    $0x16,%edx
  801855:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  80185c:	f6 c2 01             	test   $0x1,%dl
  80185f:	74 1d                	je     80187e <fd_lookup+0x41>
  801861:	89 c2                	mov    %eax,%edx
  801863:	c1 ea 0c             	shr    $0xc,%edx
  801866:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  80186d:	f6 c2 01             	test   $0x1,%dl
  801870:	74 0c                	je     80187e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] closed fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	*fd_store = fd;
  801872:	8b 55 0c             	mov    0xc(%ebp),%edx
  801875:	89 02                	mov    %eax,(%edx)
  801877:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  80187c:	eb 05                	jmp    801883 <fd_lookup+0x46>
  80187e:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801883:	5d                   	pop    %ebp
  801884:	c3                   	ret    

00801885 <seek>:
	return (*dev->dev_write)(fd, buf, n);
}

int
seek(int fdnum, off_t offset)
{
  801885:	55                   	push   %ebp
  801886:	89 e5                	mov    %esp,%ebp
  801888:	83 ec 18             	sub    $0x18,%esp
	int r;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80188b:	8d 45 fc             	lea    -0x4(%ebp),%eax
  80188e:	89 44 24 04          	mov    %eax,0x4(%esp)
  801892:	8b 45 08             	mov    0x8(%ebp),%eax
  801895:	89 04 24             	mov    %eax,(%esp)
  801898:	e8 a0 ff ff ff       	call   80183d <fd_lookup>
  80189d:	85 c0                	test   %eax,%eax
  80189f:	78 0e                	js     8018af <seek+0x2a>
		return r;
	fd->fd_offset = offset;
  8018a1:	8b 45 fc             	mov    -0x4(%ebp),%eax
  8018a4:	8b 55 0c             	mov    0xc(%ebp),%edx
  8018a7:	89 50 04             	mov    %edx,0x4(%eax)
  8018aa:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  8018af:	c9                   	leave  
  8018b0:	c3                   	ret    

008018b1 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  8018b1:	55                   	push   %ebp
  8018b2:	89 e5                	mov    %esp,%ebp
  8018b4:	56                   	push   %esi
  8018b5:	53                   	push   %ebx
  8018b6:	83 ec 10             	sub    $0x10,%esp
  8018b9:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8018bc:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
  8018bf:	ba 00 00 00 00       	mov    $0x0,%edx
int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
  8018c4:	b8 08 70 80 00       	mov    $0x807008,%eax
  8018c9:	39 0d 08 70 80 00    	cmp    %ecx,0x807008
  8018cf:	75 11                	jne    8018e2 <dev_lookup+0x31>
  8018d1:	eb 04                	jmp    8018d7 <dev_lookup+0x26>
  8018d3:	39 08                	cmp    %ecx,(%eax)
  8018d5:	75 10                	jne    8018e7 <dev_lookup+0x36>
			*dev = devtab[i];
  8018d7:	89 03                	mov    %eax,(%ebx)
  8018d9:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  8018de:	66 90                	xchg   %ax,%ax
  8018e0:	eb 36                	jmp    801918 <dev_lookup+0x67>

int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
  8018e2:	be b4 36 80 00       	mov    $0x8036b4,%esi
  8018e7:	83 c2 01             	add    $0x1,%edx
  8018ea:	8b 04 96             	mov    (%esi,%edx,4),%eax
  8018ed:	85 c0                	test   %eax,%eax
  8018ef:	75 e2                	jne    8018d3 <dev_lookup+0x22>
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", env->env_id, dev_id);
  8018f1:	a1 78 70 80 00       	mov    0x807078,%eax
  8018f6:	8b 40 4c             	mov    0x4c(%eax),%eax
  8018f9:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8018fd:	89 44 24 04          	mov    %eax,0x4(%esp)
  801901:	c7 04 24 38 36 80 00 	movl   $0x803638,(%esp)
  801908:	e8 3c eb ff ff       	call   800449 <cprintf>
	*dev = 0;
  80190d:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  801913:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
	return -E_INVAL;
}
  801918:	83 c4 10             	add    $0x10,%esp
  80191b:	5b                   	pop    %ebx
  80191c:	5e                   	pop    %esi
  80191d:	5d                   	pop    %ebp
  80191e:	c3                   	ret    

0080191f <fstat>:
	return (*dev->dev_trunc)(fd, newsize);
}

int
fstat(int fdnum, struct Stat *stat)
{
  80191f:	55                   	push   %ebp
  801920:	89 e5                	mov    %esp,%ebp
  801922:	53                   	push   %ebx
  801923:	83 ec 24             	sub    $0x24,%esp
  801926:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801929:	8d 45 f0             	lea    -0x10(%ebp),%eax
  80192c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801930:	8b 45 08             	mov    0x8(%ebp),%eax
  801933:	89 04 24             	mov    %eax,(%esp)
  801936:	e8 02 ff ff ff       	call   80183d <fd_lookup>
  80193b:	85 c0                	test   %eax,%eax
  80193d:	78 53                	js     801992 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  80193f:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801942:	89 44 24 04          	mov    %eax,0x4(%esp)
  801946:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801949:	8b 00                	mov    (%eax),%eax
  80194b:	89 04 24             	mov    %eax,(%esp)
  80194e:	e8 5e ff ff ff       	call   8018b1 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801953:	85 c0                	test   %eax,%eax
  801955:	78 3b                	js     801992 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if (!dev->dev_stat)
  801957:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  80195c:	8b 55 f4             	mov    -0xc(%ebp),%edx
  80195f:	83 7a 14 00          	cmpl   $0x0,0x14(%edx)
  801963:	74 2d                	je     801992 <fstat+0x73>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  801965:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  801968:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  80196f:	00 00 00 
	stat->st_isdir = 0;
  801972:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  801979:	00 00 00 
	stat->st_dev = dev;
  80197c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80197f:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  801985:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801989:	8b 55 f0             	mov    -0x10(%ebp),%edx
  80198c:	89 14 24             	mov    %edx,(%esp)
  80198f:	ff 50 14             	call   *0x14(%eax)
}
  801992:	83 c4 24             	add    $0x24,%esp
  801995:	5b                   	pop    %ebx
  801996:	5d                   	pop    %ebp
  801997:	c3                   	ret    

00801998 <ftruncate>:
	return 0;
}

int
ftruncate(int fdnum, off_t newsize)
{
  801998:	55                   	push   %ebp
  801999:	89 e5                	mov    %esp,%ebp
  80199b:	53                   	push   %ebx
  80199c:	83 ec 24             	sub    $0x24,%esp
  80199f:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  8019a2:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8019a5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8019a9:	89 1c 24             	mov    %ebx,(%esp)
  8019ac:	e8 8c fe ff ff       	call   80183d <fd_lookup>
  8019b1:	85 c0                	test   %eax,%eax
  8019b3:	78 5f                	js     801a14 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8019b5:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8019b8:	89 44 24 04          	mov    %eax,0x4(%esp)
  8019bc:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8019bf:	8b 00                	mov    (%eax),%eax
  8019c1:	89 04 24             	mov    %eax,(%esp)
  8019c4:	e8 e8 fe ff ff       	call   8018b1 <dev_lookup>
ftruncate(int fdnum, off_t newsize)
{
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  8019c9:	85 c0                	test   %eax,%eax
  8019cb:	78 47                	js     801a14 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  8019cd:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8019d0:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  8019d4:	75 23                	jne    8019f9 <ftruncate+0x61>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			env->env_id, fdnum); 
  8019d6:	a1 78 70 80 00       	mov    0x807078,%eax
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  8019db:	8b 40 4c             	mov    0x4c(%eax),%eax
  8019de:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8019e2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8019e6:	c7 04 24 58 36 80 00 	movl   $0x803658,(%esp)
  8019ed:	e8 57 ea ff ff       	call   800449 <cprintf>
  8019f2:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
			env->env_id, fdnum); 
		return -E_INVAL;
  8019f7:	eb 1b                	jmp    801a14 <ftruncate+0x7c>
	}
	if (!dev->dev_trunc)
  8019f9:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8019fc:	8b 48 18             	mov    0x18(%eax),%ecx
  8019ff:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801a04:	85 c9                	test   %ecx,%ecx
  801a06:	74 0c                	je     801a14 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  801a08:	8b 45 0c             	mov    0xc(%ebp),%eax
  801a0b:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a0f:	89 14 24             	mov    %edx,(%esp)
  801a12:	ff d1                	call   *%ecx
}
  801a14:	83 c4 24             	add    $0x24,%esp
  801a17:	5b                   	pop    %ebx
  801a18:	5d                   	pop    %ebp
  801a19:	c3                   	ret    

00801a1a <write>:
	return tot;
}

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  801a1a:	55                   	push   %ebp
  801a1b:	89 e5                	mov    %esp,%ebp
  801a1d:	53                   	push   %ebx
  801a1e:	83 ec 24             	sub    $0x24,%esp
  801a21:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801a24:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801a27:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a2b:	89 1c 24             	mov    %ebx,(%esp)
  801a2e:	e8 0a fe ff ff       	call   80183d <fd_lookup>
  801a33:	85 c0                	test   %eax,%eax
  801a35:	78 66                	js     801a9d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801a37:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801a3a:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a3e:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801a41:	8b 00                	mov    (%eax),%eax
  801a43:	89 04 24             	mov    %eax,(%esp)
  801a46:	e8 66 fe ff ff       	call   8018b1 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801a4b:	85 c0                	test   %eax,%eax
  801a4d:	78 4e                	js     801a9d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  801a4f:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801a52:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801a56:	75 23                	jne    801a7b <write+0x61>
		cprintf("[%08x] write %d -- bad mode\n", env->env_id, fdnum);
  801a58:	a1 78 70 80 00       	mov    0x807078,%eax
  801a5d:	8b 40 4c             	mov    0x4c(%eax),%eax
  801a60:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801a64:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a68:	c7 04 24 79 36 80 00 	movl   $0x803679,(%esp)
  801a6f:	e8 d5 e9 ff ff       	call   800449 <cprintf>
  801a74:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801a79:	eb 22                	jmp    801a9d <write+0x83>
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  801a7b:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801a7e:	8b 48 0c             	mov    0xc(%eax),%ecx
  801a81:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801a86:	85 c9                	test   %ecx,%ecx
  801a88:	74 13                	je     801a9d <write+0x83>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  801a8a:	8b 45 10             	mov    0x10(%ebp),%eax
  801a8d:	89 44 24 08          	mov    %eax,0x8(%esp)
  801a91:	8b 45 0c             	mov    0xc(%ebp),%eax
  801a94:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a98:	89 14 24             	mov    %edx,(%esp)
  801a9b:	ff d1                	call   *%ecx
}
  801a9d:	83 c4 24             	add    $0x24,%esp
  801aa0:	5b                   	pop    %ebx
  801aa1:	5d                   	pop    %ebp
  801aa2:	c3                   	ret    

00801aa3 <read>:
	return r;
}

ssize_t
read(int fdnum, void *buf, size_t n)
{
  801aa3:	55                   	push   %ebp
  801aa4:	89 e5                	mov    %esp,%ebp
  801aa6:	57                   	push   %edi
  801aa7:	56                   	push   %esi
  801aa8:	53                   	push   %ebx
  801aa9:	83 ec 2c             	sub    $0x2c,%esp
  801aac:	8b 5d 08             	mov    0x8(%ebp),%ebx
  801aaf:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801ab2:	8d 45 e0             	lea    -0x20(%ebp),%eax
  801ab5:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ab9:	89 1c 24             	mov    %ebx,(%esp)
  801abc:	e8 7c fd ff ff       	call   80183d <fd_lookup>
  801ac1:	85 c0                	test   %eax,%eax
  801ac3:	0f 88 b0 00 00 00    	js     801b79 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801ac9:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801acc:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ad0:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801ad3:	8b 00                	mov    (%eax),%eax
  801ad5:	89 04 24             	mov    %eax,(%esp)
  801ad8:	e8 d4 fd ff ff       	call   8018b1 <dev_lookup>
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801add:	85 c0                	test   %eax,%eax
  801adf:	0f 88 94 00 00 00    	js     801b79 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  801ae5:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801ae8:	8b 40 08             	mov    0x8(%eax),%eax
  801aeb:	83 e0 03             	and    $0x3,%eax
  801aee:	83 f8 01             	cmp    $0x1,%eax
  801af1:	75 23                	jne    801b16 <read+0x73>
		cprintf("[%08x] read %d -- bad mode\n", env->env_id, fdnum); 
  801af3:	a1 78 70 80 00       	mov    0x807078,%eax
  801af8:	8b 40 4c             	mov    0x4c(%eax),%eax
  801afb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801aff:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b03:	c7 04 24 96 36 80 00 	movl   $0x803696,(%esp)
  801b0a:	e8 3a e9 ff ff       	call   800449 <cprintf>
  801b0f:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801b14:	eb 63                	jmp    801b79 <read+0xd6>
	}
	if (!dev->dev_read)
  801b16:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801b1b:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  801b1e:	83 7a 08 00          	cmpl   $0x0,0x8(%edx)
  801b22:	74 55                	je     801b79 <read+0xd6>
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  801b24:	ba 00 00 00 00       	mov    $0x0,%edx
  801b29:	bb 00 00 00 00       	mov    $0x0,%ebx
  801b2e:	b8 00 00 00 00       	mov    $0x0,%eax
  801b33:	85 f6                	test   %esi,%esi
  801b35:	74 42                	je     801b79 <read+0xd6>
    int count=0;
    if ((n-tot)/PGSIZE == 0)
  801b37:	bf 00 10 00 00       	mov    $0x1000,%edi
  801b3c:	89 f0                	mov    %esi,%eax
  801b3e:	29 d0                	sub    %edx,%eax
  801b40:	89 c1                	mov    %eax,%ecx
  801b42:	81 e1 ff 0f 00 00    	and    $0xfff,%ecx
  801b48:	3d 00 10 00 00       	cmp    $0x1000,%eax
  801b4d:	0f 43 cf             	cmovae %edi,%ecx
      count = (n-tot)%PGSIZE;
    else
      count = PGSIZE;

	  m = (*dev->dev_read)(fd, (char *)buf + tot, count);
  801b50:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  801b54:	03 55 0c             	add    0xc(%ebp),%edx
  801b57:	89 54 24 04          	mov    %edx,0x4(%esp)
  801b5b:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801b5e:	89 04 24             	mov    %eax,(%esp)
  801b61:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801b64:	ff 50 08             	call   *0x8(%eax)
		if (m < 0)
  801b67:	85 c0                	test   %eax,%eax
  801b69:	78 0e                	js     801b79 <read+0xd6>
			return m;
		if (m == 0)
  801b6b:	85 c0                	test   %eax,%eax
  801b6d:	74 08                	je     801b77 <read+0xd4>
		return -E_INVAL;
	}
	if (!dev->dev_read)
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  801b6f:	01 c3                	add    %eax,%ebx
  801b71:	89 da                	mov    %ebx,%edx
  801b73:	39 f3                	cmp    %esi,%ebx
  801b75:	72 c5                	jb     801b3c <read+0x99>
  801b77:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  801b79:	83 c4 2c             	add    $0x2c,%esp
  801b7c:	5b                   	pop    %ebx
  801b7d:	5e                   	pop    %esi
  801b7e:	5f                   	pop    %edi
  801b7f:	5d                   	pop    %ebp
  801b80:	c3                   	ret    

00801b81 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  801b81:	55                   	push   %ebp
  801b82:	89 e5                	mov    %esp,%ebp
  801b84:	57                   	push   %edi
  801b85:	56                   	push   %esi
  801b86:	53                   	push   %ebx
  801b87:	83 ec 1c             	sub    $0x1c,%esp
  801b8a:	8b 7d 08             	mov    0x8(%ebp),%edi
  801b8d:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801b90:	ba 00 00 00 00       	mov    $0x0,%edx
  801b95:	bb 00 00 00 00       	mov    $0x0,%ebx
  801b9a:	b8 00 00 00 00       	mov    $0x0,%eax
  801b9f:	85 f6                	test   %esi,%esi
  801ba1:	74 29                	je     801bcc <readn+0x4b>
		m = read(fdnum, (char*)buf + tot, n - tot);
  801ba3:	89 f0                	mov    %esi,%eax
  801ba5:	29 d0                	sub    %edx,%eax
  801ba7:	89 44 24 08          	mov    %eax,0x8(%esp)
  801bab:	03 55 0c             	add    0xc(%ebp),%edx
  801bae:	89 54 24 04          	mov    %edx,0x4(%esp)
  801bb2:	89 3c 24             	mov    %edi,(%esp)
  801bb5:	e8 e9 fe ff ff       	call   801aa3 <read>
		if (m < 0)
  801bba:	85 c0                	test   %eax,%eax
  801bbc:	78 0e                	js     801bcc <readn+0x4b>
			return m;
		if (m == 0)
  801bbe:	85 c0                	test   %eax,%eax
  801bc0:	74 08                	je     801bca <readn+0x49>
readn(int fdnum, void *buf, size_t n)
{
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801bc2:	01 c3                	add    %eax,%ebx
  801bc4:	89 da                	mov    %ebx,%edx
  801bc6:	39 f3                	cmp    %esi,%ebx
  801bc8:	72 d9                	jb     801ba3 <readn+0x22>
  801bca:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  801bcc:	83 c4 1c             	add    $0x1c,%esp
  801bcf:	5b                   	pop    %ebx
  801bd0:	5e                   	pop    %esi
  801bd1:	5f                   	pop    %edi
  801bd2:	5d                   	pop    %ebp
  801bd3:	c3                   	ret    

00801bd4 <fd_close>:
// If 'must_exist' is 1, then fd_close returns -E_INVAL when passed a
// closed or nonexistent file descriptor.
// Returns 0 on success, < 0 on error.
int
fd_close(struct Fd *fd, bool must_exist)
{
  801bd4:	55                   	push   %ebp
  801bd5:	89 e5                	mov    %esp,%ebp
  801bd7:	83 ec 28             	sub    $0x28,%esp
  801bda:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801bdd:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801be0:	8b 75 08             	mov    0x8(%ebp),%esi
	struct Fd *fd2;
	struct Dev *dev;
	int r;
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  801be3:	89 34 24             	mov    %esi,(%esp)
  801be6:	e8 b5 fb ff ff       	call   8017a0 <fd2num>
  801beb:	8d 55 f4             	lea    -0xc(%ebp),%edx
  801bee:	89 54 24 04          	mov    %edx,0x4(%esp)
  801bf2:	89 04 24             	mov    %eax,(%esp)
  801bf5:	e8 43 fc ff ff       	call   80183d <fd_lookup>
  801bfa:	89 c3                	mov    %eax,%ebx
  801bfc:	85 c0                	test   %eax,%eax
  801bfe:	78 05                	js     801c05 <fd_close+0x31>
  801c00:	3b 75 f4             	cmp    -0xc(%ebp),%esi
  801c03:	74 0e                	je     801c13 <fd_close+0x3f>
	    || fd != fd2)
		return (must_exist ? r : 0);
  801c05:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  801c09:	b8 00 00 00 00       	mov    $0x0,%eax
  801c0e:	0f 44 d8             	cmove  %eax,%ebx
  801c11:	eb 3d                	jmp    801c50 <fd_close+0x7c>
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  801c13:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801c16:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c1a:	8b 06                	mov    (%esi),%eax
  801c1c:	89 04 24             	mov    %eax,(%esp)
  801c1f:	e8 8d fc ff ff       	call   8018b1 <dev_lookup>
  801c24:	89 c3                	mov    %eax,%ebx
  801c26:	85 c0                	test   %eax,%eax
  801c28:	78 16                	js     801c40 <fd_close+0x6c>
		if (dev->dev_close)
  801c2a:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801c2d:	8b 40 10             	mov    0x10(%eax),%eax
  801c30:	bb 00 00 00 00       	mov    $0x0,%ebx
  801c35:	85 c0                	test   %eax,%eax
  801c37:	74 07                	je     801c40 <fd_close+0x6c>
			r = (*dev->dev_close)(fd);
  801c39:	89 34 24             	mov    %esi,(%esp)
  801c3c:	ff d0                	call   *%eax
  801c3e:	89 c3                	mov    %eax,%ebx
		else
			r = 0;
	}
	// Make sure fd is unmapped.  Might be a no-op if
	// (*dev->dev_close)(fd) already unmapped it.
	(void) sys_page_unmap(0, fd);
  801c40:	89 74 24 04          	mov    %esi,0x4(%esp)
  801c44:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801c4b:	e8 6a f5 ff ff       	call   8011ba <sys_page_unmap>
	return r;
}
  801c50:	89 d8                	mov    %ebx,%eax
  801c52:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801c55:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801c58:	89 ec                	mov    %ebp,%esp
  801c5a:	5d                   	pop    %ebp
  801c5b:	c3                   	ret    

00801c5c <close>:
	return -E_INVAL;
}

int
close(int fdnum)
{
  801c5c:	55                   	push   %ebp
  801c5d:	89 e5                	mov    %esp,%ebp
  801c5f:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  801c62:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801c65:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c69:	8b 45 08             	mov    0x8(%ebp),%eax
  801c6c:	89 04 24             	mov    %eax,(%esp)
  801c6f:	e8 c9 fb ff ff       	call   80183d <fd_lookup>
  801c74:	85 c0                	test   %eax,%eax
  801c76:	78 13                	js     801c8b <close+0x2f>
		return r;
	else
		return fd_close(fd, 1);
  801c78:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  801c7f:	00 
  801c80:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801c83:	89 04 24             	mov    %eax,(%esp)
  801c86:	e8 49 ff ff ff       	call   801bd4 <fd_close>
}
  801c8b:	c9                   	leave  
  801c8c:	c3                   	ret    

00801c8d <stat>:
	return (*dev->dev_stat)(fd, stat);
}

int
stat(const char *path, struct Stat *stat)
{
  801c8d:	55                   	push   %ebp
  801c8e:	89 e5                	mov    %esp,%ebp
  801c90:	83 ec 18             	sub    $0x18,%esp
  801c93:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801c96:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  801c99:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801ca0:	00 
  801ca1:	8b 45 08             	mov    0x8(%ebp),%eax
  801ca4:	89 04 24             	mov    %eax,(%esp)
  801ca7:	e8 80 03 00 00       	call   80202c <open>
  801cac:	89 c3                	mov    %eax,%ebx
  801cae:	85 c0                	test   %eax,%eax
  801cb0:	78 1b                	js     801ccd <stat+0x40>
		return fd;
	r = fstat(fd, stat);
  801cb2:	8b 45 0c             	mov    0xc(%ebp),%eax
  801cb5:	89 44 24 04          	mov    %eax,0x4(%esp)
  801cb9:	89 1c 24             	mov    %ebx,(%esp)
  801cbc:	e8 5e fc ff ff       	call   80191f <fstat>
  801cc1:	89 c6                	mov    %eax,%esi
	close(fd);
  801cc3:	89 1c 24             	mov    %ebx,(%esp)
  801cc6:	e8 91 ff ff ff       	call   801c5c <close>
  801ccb:	89 f3                	mov    %esi,%ebx
	return r;
}
  801ccd:	89 d8                	mov    %ebx,%eax
  801ccf:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801cd2:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801cd5:	89 ec                	mov    %ebp,%esp
  801cd7:	5d                   	pop    %ebp
  801cd8:	c3                   	ret    

00801cd9 <close_all>:
		return fd_close(fd, 1);
}

void
close_all(void)
{
  801cd9:	55                   	push   %ebp
  801cda:	89 e5                	mov    %esp,%ebp
  801cdc:	53                   	push   %ebx
  801cdd:	83 ec 14             	sub    $0x14,%esp
  801ce0:	bb 00 00 00 00       	mov    $0x0,%ebx
	int i;
	for (i = 0; i < MAXFD; i++)
		close(i);
  801ce5:	89 1c 24             	mov    %ebx,(%esp)
  801ce8:	e8 6f ff ff ff       	call   801c5c <close>

void
close_all(void)
{
	int i;
	for (i = 0; i < MAXFD; i++)
  801ced:	83 c3 01             	add    $0x1,%ebx
  801cf0:	83 fb 20             	cmp    $0x20,%ebx
  801cf3:	75 f0                	jne    801ce5 <close_all+0xc>
		close(i);
}
  801cf5:	83 c4 14             	add    $0x14,%esp
  801cf8:	5b                   	pop    %ebx
  801cf9:	5d                   	pop    %ebp
  801cfa:	c3                   	ret    

00801cfb <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  801cfb:	55                   	push   %ebp
  801cfc:	89 e5                	mov    %esp,%ebp
  801cfe:	83 ec 58             	sub    $0x58,%esp
  801d01:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801d04:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801d07:	89 7d fc             	mov    %edi,-0x4(%ebp)
  801d0a:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  801d0d:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801d10:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d14:	8b 45 08             	mov    0x8(%ebp),%eax
  801d17:	89 04 24             	mov    %eax,(%esp)
  801d1a:	e8 1e fb ff ff       	call   80183d <fd_lookup>
  801d1f:	89 c3                	mov    %eax,%ebx
  801d21:	85 c0                	test   %eax,%eax
  801d23:	0f 88 e0 00 00 00    	js     801e09 <dup+0x10e>
		return r;
	close(newfdnum);
  801d29:	89 3c 24             	mov    %edi,(%esp)
  801d2c:	e8 2b ff ff ff       	call   801c5c <close>

	newfd = INDEX2FD(newfdnum);
  801d31:	8d b7 00 00 0d 00    	lea    0xd0000(%edi),%esi
  801d37:	c1 e6 0c             	shl    $0xc,%esi
	ova = fd2data(oldfd);
  801d3a:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801d3d:	89 04 24             	mov    %eax,(%esp)
  801d40:	e8 6b fa ff ff       	call   8017b0 <fd2data>
  801d45:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  801d47:	89 34 24             	mov    %esi,(%esp)
  801d4a:	e8 61 fa ff ff       	call   8017b0 <fd2data>
  801d4f:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	if ((vpd[PDX(ova)] & PTE_P) && (vpt[VPN(ova)] & PTE_P))
  801d52:	89 da                	mov    %ebx,%edx
  801d54:	89 d8                	mov    %ebx,%eax
  801d56:	c1 e8 16             	shr    $0x16,%eax
  801d59:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  801d60:	a8 01                	test   $0x1,%al
  801d62:	74 43                	je     801da7 <dup+0xac>
  801d64:	c1 ea 0c             	shr    $0xc,%edx
  801d67:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801d6e:	a8 01                	test   $0x1,%al
  801d70:	74 35                	je     801da7 <dup+0xac>
		if ((r = sys_page_map(0, ova, 0, nva, (vpt[VPN(ova)]) & PTE_USER)) < 0)
  801d72:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801d79:	25 07 0e 00 00       	and    $0xe07,%eax
  801d7e:	89 44 24 10          	mov    %eax,0x10(%esp)
  801d82:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801d85:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801d89:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801d90:	00 
  801d91:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801d95:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801d9c:	e8 77 f4 ff ff       	call   801218 <sys_page_map>
  801da1:	89 c3                	mov    %eax,%ebx
  801da3:	85 c0                	test   %eax,%eax
  801da5:	78 3f                	js     801de6 <dup+0xeb>
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, (vpt[VPN(oldfd)]) & PTE_USER)) < 0)
  801da7:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801daa:	89 c2                	mov    %eax,%edx
  801dac:	c1 ea 0c             	shr    $0xc,%edx
  801daf:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801db6:	81 e2 07 0e 00 00    	and    $0xe07,%edx
  801dbc:	89 54 24 10          	mov    %edx,0x10(%esp)
  801dc0:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801dc4:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801dcb:	00 
  801dcc:	89 44 24 04          	mov    %eax,0x4(%esp)
  801dd0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801dd7:	e8 3c f4 ff ff       	call   801218 <sys_page_map>
  801ddc:	89 c3                	mov    %eax,%ebx
  801dde:	85 c0                	test   %eax,%eax
  801de0:	78 04                	js     801de6 <dup+0xeb>
  801de2:	89 fb                	mov    %edi,%ebx
  801de4:	eb 23                	jmp    801e09 <dup+0x10e>
		goto err;

	return newfdnum;
err:
	sys_page_unmap(0, newfd);
  801de6:	89 74 24 04          	mov    %esi,0x4(%esp)
  801dea:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801df1:	e8 c4 f3 ff ff       	call   8011ba <sys_page_unmap>
	sys_page_unmap(0, nva);
  801df6:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801df9:	89 44 24 04          	mov    %eax,0x4(%esp)
  801dfd:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801e04:	e8 b1 f3 ff ff       	call   8011ba <sys_page_unmap>
	return r;
}
  801e09:	89 d8                	mov    %ebx,%eax
  801e0b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801e0e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801e11:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801e14:	89 ec                	mov    %ebp,%esp
  801e16:	5d                   	pop    %ebp
  801e17:	c3                   	ret    

00801e18 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  801e18:	55                   	push   %ebp
  801e19:	89 e5                	mov    %esp,%ebp
  801e1b:	53                   	push   %ebx
  801e1c:	83 ec 14             	sub    $0x14,%esp
  801e1f:	89 d3                	mov    %edx,%ebx
	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", env->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(envs[1].env_id, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  801e21:	8b 15 c8 00 c0 ee    	mov    0xeec000c8,%edx
  801e27:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  801e2e:	00 
  801e2f:	c7 44 24 08 00 40 80 	movl   $0x804000,0x8(%esp)
  801e36:	00 
  801e37:	89 44 24 04          	mov    %eax,0x4(%esp)
  801e3b:	89 14 24             	mov    %edx,(%esp)
  801e3e:	e8 ed 0d 00 00       	call   802c30 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  801e43:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801e4a:	00 
  801e4b:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801e4f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801e56:	e8 47 0e 00 00       	call   802ca2 <ipc_recv>
}
  801e5b:	83 c4 14             	add    $0x14,%esp
  801e5e:	5b                   	pop    %ebx
  801e5f:	5d                   	pop    %ebp
  801e60:	c3                   	ret    

00801e61 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  801e61:	55                   	push   %ebp
  801e62:	89 e5                	mov    %esp,%ebp
  801e64:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  801e67:	8b 45 08             	mov    0x8(%ebp),%eax
  801e6a:	8b 40 0c             	mov    0xc(%eax),%eax
  801e6d:	a3 00 40 80 00       	mov    %eax,0x804000
	fsipcbuf.set_size.req_size = newsize;
  801e72:	8b 45 0c             	mov    0xc(%ebp),%eax
  801e75:	a3 04 40 80 00       	mov    %eax,0x804004
	return fsipc(FSREQ_SET_SIZE, NULL);
  801e7a:	ba 00 00 00 00       	mov    $0x0,%edx
  801e7f:	b8 02 00 00 00       	mov    $0x2,%eax
  801e84:	e8 8f ff ff ff       	call   801e18 <fsipc>
}
  801e89:	c9                   	leave  
  801e8a:	c3                   	ret    

00801e8b <devfile_flush>:
// open, unmapping it is enough to free up server-side resources.
// Other than that, we just have to make sure our changes are flushed
// to disk.
static int
devfile_flush(struct Fd *fd)
{
  801e8b:	55                   	push   %ebp
  801e8c:	89 e5                	mov    %esp,%ebp
  801e8e:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  801e91:	8b 45 08             	mov    0x8(%ebp),%eax
  801e94:	8b 40 0c             	mov    0xc(%eax),%eax
  801e97:	a3 00 40 80 00       	mov    %eax,0x804000
	return fsipc(FSREQ_FLUSH, NULL);
  801e9c:	ba 00 00 00 00       	mov    $0x0,%edx
  801ea1:	b8 06 00 00 00       	mov    $0x6,%eax
  801ea6:	e8 6d ff ff ff       	call   801e18 <fsipc>
}
  801eab:	c9                   	leave  
  801eac:	c3                   	ret    

00801ead <sync>:
}

// Synchronize disk with buffer cache
int
sync(void)
{
  801ead:	55                   	push   %ebp
  801eae:	89 e5                	mov    %esp,%ebp
  801eb0:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  801eb3:	ba 00 00 00 00       	mov    $0x0,%edx
  801eb8:	b8 08 00 00 00       	mov    $0x8,%eax
  801ebd:	e8 56 ff ff ff       	call   801e18 <fsipc>
}
  801ec2:	c9                   	leave  
  801ec3:	c3                   	ret    

00801ec4 <devfile_stat>:
    return n;
}

static int
devfile_stat(struct Fd *fd, struct Stat *st)
{
  801ec4:	55                   	push   %ebp
  801ec5:	89 e5                	mov    %esp,%ebp
  801ec7:	53                   	push   %ebx
  801ec8:	83 ec 14             	sub    $0x14,%esp
  801ecb:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;

	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  801ece:	8b 45 08             	mov    0x8(%ebp),%eax
  801ed1:	8b 40 0c             	mov    0xc(%eax),%eax
  801ed4:	a3 00 40 80 00       	mov    %eax,0x804000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  801ed9:	ba 00 00 00 00       	mov    $0x0,%edx
  801ede:	b8 05 00 00 00       	mov    $0x5,%eax
  801ee3:	e8 30 ff ff ff       	call   801e18 <fsipc>
  801ee8:	85 c0                	test   %eax,%eax
  801eea:	78 2b                	js     801f17 <devfile_stat+0x53>
		return r;
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  801eec:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  801ef3:	00 
  801ef4:	89 1c 24             	mov    %ebx,(%esp)
  801ef7:	e8 1e ec ff ff       	call   800b1a <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  801efc:	a1 80 40 80 00       	mov    0x804080,%eax
  801f01:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  801f07:	a1 84 40 80 00       	mov    0x804084,%eax
  801f0c:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  801f12:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  801f17:	83 c4 14             	add    $0x14,%esp
  801f1a:	5b                   	pop    %ebx
  801f1b:	5d                   	pop    %ebp
  801f1c:	c3                   	ret    

00801f1d <devfile_write>:
// Returns:
//	 The number of bytes successfully written.
//	 < 0 on error.
static ssize_t
devfile_write(struct Fd *fd, const void *buf, size_t n)
{
  801f1d:	55                   	push   %ebp
  801f1e:	89 e5                	mov    %esp,%ebp
  801f20:	53                   	push   %ebx
  801f21:	83 ec 14             	sub    $0x14,%esp
  801f24:	8b 45 08             	mov    0x8(%ebp),%eax
  801f27:	8b 55 0c             	mov    0xc(%ebp),%edx
  801f2a:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// careful: fsipcbuf.write.req_buf is only so large, but
	// remember that write is always allowed to write *fewer*
	// bytes than requested.
	// LAB 5: Your code here
    int r;
    if (!fd || !buf || (n>(PGSIZE-sizeof(size_t)-sizeof(int))))
  801f2d:	85 c0                	test   %eax,%eax
  801f2f:	74 44                	je     801f75 <devfile_write+0x58>
  801f31:	85 d2                	test   %edx,%edx
  801f33:	74 40                	je     801f75 <devfile_write+0x58>
  801f35:	81 fb f8 0f 00 00    	cmp    $0xff8,%ebx
  801f3b:	77 38                	ja     801f75 <devfile_write+0x58>
        return -E_INVAL;

    fsipcbuf.write.req_fileid   = fd->fd_file.id;
  801f3d:	8b 40 0c             	mov    0xc(%eax),%eax
  801f40:	a3 00 40 80 00       	mov    %eax,0x804000
    fsipcbuf.write.req_n        = n;
  801f45:	89 1d 04 40 80 00    	mov    %ebx,0x804004
    memmove(fsipcbuf.write.req_buf, buf, n);
  801f4b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801f4f:	89 54 24 04          	mov    %edx,0x4(%esp)
  801f53:	c7 04 24 08 40 80 00 	movl   $0x804008,(%esp)
  801f5a:	e8 76 ed ff ff       	call   800cd5 <memmove>
    if ((r=fsipc(FSREQ_WRITE, NULL))<0)
  801f5f:	ba 00 00 00 00       	mov    $0x0,%edx
  801f64:	b8 04 00 00 00       	mov    $0x4,%eax
  801f69:	e8 aa fe ff ff       	call   801e18 <fsipc>
        return r;
    return n;
  801f6e:	85 c0                	test   %eax,%eax
  801f70:	0f 49 c3             	cmovns %ebx,%eax
  801f73:	eb 05                	jmp    801f7a <devfile_write+0x5d>
  801f75:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801f7a:	83 c4 14             	add    $0x14,%esp
  801f7d:	5b                   	pop    %ebx
  801f7e:	5d                   	pop    %ebp
  801f7f:	c3                   	ret    

00801f80 <devfile_read>:
// Returns:
// 	The number of bytes successfully read.
// 	< 0 on error.
static ssize_t
devfile_read(struct Fd *fd, void *buf, size_t n)
{
  801f80:	55                   	push   %ebp
  801f81:	89 e5                	mov    %esp,%ebp
  801f83:	83 ec 18             	sub    $0x18,%esp
  801f86:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801f89:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801f8c:	8b 45 08             	mov    0x8(%ebp),%eax
  801f8f:	8b 75 0c             	mov    0xc(%ebp),%esi
	// filling fsipcbuf.read with the request arguments.  The
	// bytes read will be written back to fsipcbuf by the file
	// system server.
	// LAB 5: Your code here
  int r;
  if (!fd || !buf)
  801f92:	85 c0                	test   %eax,%eax
  801f94:	74 04                	je     801f9a <devfile_read+0x1a>
  801f96:	85 f6                	test   %esi,%esi
  801f98:	75 07                	jne    801fa1 <devfile_read+0x21>
  801f9a:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  801f9f:	eb 39                	jmp    801fda <devfile_read+0x5a>
    return -E_INVAL;

  fsipcbuf.read.req_fileid    = fd->fd_file.id;
  801fa1:	8b 40 0c             	mov    0xc(%eax),%eax
  801fa4:	a3 00 40 80 00       	mov    %eax,0x804000
  fsipcbuf.read.req_n         = n;
  801fa9:	8b 45 10             	mov    0x10(%ebp),%eax
  801fac:	a3 04 40 80 00       	mov    %eax,0x804004
  if ((r=fsipc(FSREQ_READ, NULL))<0)
  801fb1:	ba 00 00 00 00       	mov    $0x0,%edx
  801fb6:	b8 03 00 00 00       	mov    $0x3,%eax
  801fbb:	e8 58 fe ff ff       	call   801e18 <fsipc>
  801fc0:	89 c3                	mov    %eax,%ebx
  801fc2:	85 c0                	test   %eax,%eax
  801fc4:	78 14                	js     801fda <devfile_read+0x5a>
    return r;

  memmove(buf, fsipcbuf.readRet.ret_buf, r);
  801fc6:	89 44 24 08          	mov    %eax,0x8(%esp)
  801fca:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  801fd1:	00 
  801fd2:	89 34 24             	mov    %esi,(%esp)
  801fd5:	e8 fb ec ff ff       	call   800cd5 <memmove>
  return r;
}
  801fda:	89 d8                	mov    %ebx,%eax
  801fdc:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801fdf:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801fe2:	89 ec                	mov    %ebp,%esp
  801fe4:	5d                   	pop    %ebp
  801fe5:	c3                   	ret    

00801fe6 <remove>:
}

// Delete a file
int
remove(const char *path)
{
  801fe6:	55                   	push   %ebp
  801fe7:	89 e5                	mov    %esp,%ebp
  801fe9:	53                   	push   %ebx
  801fea:	83 ec 14             	sub    $0x14,%esp
  801fed:	8b 5d 08             	mov    0x8(%ebp),%ebx
	if (strlen(path) >= MAXPATHLEN)
  801ff0:	89 1c 24             	mov    %ebx,(%esp)
  801ff3:	e8 d8 ea ff ff       	call   800ad0 <strlen>
  801ff8:	89 c2                	mov    %eax,%edx
  801ffa:	b8 f4 ff ff ff       	mov    $0xfffffff4,%eax
  801fff:	81 fa ff 03 00 00    	cmp    $0x3ff,%edx
  802005:	7f 1f                	jg     802026 <remove+0x40>
		return -E_BAD_PATH;
	strcpy(fsipcbuf.remove.req_path, path);
  802007:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80200b:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  802012:	e8 03 eb ff ff       	call   800b1a <strcpy>
	return fsipc(FSREQ_REMOVE, NULL);
  802017:	ba 00 00 00 00       	mov    $0x0,%edx
  80201c:	b8 07 00 00 00       	mov    $0x7,%eax
  802021:	e8 f2 fd ff ff       	call   801e18 <fsipc>
}
  802026:	83 c4 14             	add    $0x14,%esp
  802029:	5b                   	pop    %ebx
  80202a:	5d                   	pop    %ebp
  80202b:	c3                   	ret    

0080202c <open>:
// 	The file descriptor index on success
// 	-E_BAD_PATH if the path is too long (>= MAXPATHLEN)
// 	< 0 for other errors.
int
open(const char *path, int mode)
{
  80202c:	55                   	push   %ebp
  80202d:	89 e5                	mov    %esp,%ebp
  80202f:	83 ec 28             	sub    $0x28,%esp
  802032:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802035:	89 75 fc             	mov    %esi,-0x4(%ebp)
  802038:	8b 75 08             	mov    0x8(%ebp),%esi
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  int r   = 0;

  if (!path)
  80203b:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  802040:	85 f6                	test   %esi,%esi
  802042:	74 65                	je     8020a9 <open+0x7d>
	// (fd_alloc does not allocate a page, it just returns an
	// unused fd address.  Do you need to allocate a page?)
	//
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  802044:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  int r   = 0;

  if (!path)
    return -E_INVAL;
  if((r=fd_alloc(&f))<0)
  80204b:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80204e:	89 04 24             	mov    %eax,(%esp)
  802051:	e8 75 f7 ff ff       	call   8017cb <fd_alloc>
  802056:	89 c3                	mov    %eax,%ebx
  802058:	85 c0                	test   %eax,%eax
  80205a:	78 4d                	js     8020a9 <open+0x7d>
    return r;

	strcpy(fsipcbuf.open.req_path, path);
  80205c:	89 74 24 04          	mov    %esi,0x4(%esp)
  802060:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  802067:	e8 ae ea ff ff       	call   800b1a <strcpy>
	fsipcbuf.open.req_omode = mode;
  80206c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80206f:	a3 00 44 80 00       	mov    %eax,0x804400

  if ((r=fsipc(FSREQ_OPEN, f))<0) {
  802074:	8b 55 f4             	mov    -0xc(%ebp),%edx
  802077:	b8 01 00 00 00       	mov    $0x1,%eax
  80207c:	e8 97 fd ff ff       	call   801e18 <fsipc>
  802081:	89 c3                	mov    %eax,%ebx
  802083:	85 c0                	test   %eax,%eax
  802085:	79 15                	jns    80209c <open+0x70>
    fd_close(f, 0);
  802087:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  80208e:	00 
  80208f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802092:	89 04 24             	mov    %eax,(%esp)
  802095:	e8 3a fb ff ff       	call   801bd4 <fd_close>
    return r;
  80209a:	eb 0d                	jmp    8020a9 <open+0x7d>
  }
  return fd2num(f);
  80209c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80209f:	89 04 24             	mov    %eax,(%esp)
  8020a2:	e8 f9 f6 ff ff       	call   8017a0 <fd2num>
  8020a7:	89 c3                	mov    %eax,%ebx
}
  8020a9:	89 d8                	mov    %ebx,%eax
  8020ab:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8020ae:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8020b1:	89 ec                	mov    %ebp,%esp
  8020b3:	5d                   	pop    %ebp
  8020b4:	c3                   	ret    
	...

008020c0 <devsock_stat>:
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
}

static int
devsock_stat(struct Fd *fd, struct Stat *stat)
{
  8020c0:	55                   	push   %ebp
  8020c1:	89 e5                	mov    %esp,%ebp
  8020c3:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<sock>");
  8020c6:	c7 44 24 04 c8 36 80 	movl   $0x8036c8,0x4(%esp)
  8020cd:	00 
  8020ce:	8b 45 0c             	mov    0xc(%ebp),%eax
  8020d1:	89 04 24             	mov    %eax,(%esp)
  8020d4:	e8 41 ea ff ff       	call   800b1a <strcpy>
	return 0;
}
  8020d9:	b8 00 00 00 00       	mov    $0x0,%eax
  8020de:	c9                   	leave  
  8020df:	c3                   	ret    

008020e0 <devsock_close>:
	return nsipc_shutdown(r, how);
}

static int
devsock_close(struct Fd *fd)
{
  8020e0:	55                   	push   %ebp
  8020e1:	89 e5                	mov    %esp,%ebp
  8020e3:	83 ec 18             	sub    $0x18,%esp
	return nsipc_close(fd->fd_sock.sockid);
  8020e6:	8b 45 08             	mov    0x8(%ebp),%eax
  8020e9:	8b 40 0c             	mov    0xc(%eax),%eax
  8020ec:	89 04 24             	mov    %eax,(%esp)
  8020ef:	e8 9d 02 00 00       	call   802391 <nsipc_close>
}
  8020f4:	c9                   	leave  
  8020f5:	c3                   	ret    

008020f6 <devsock_write>:
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
}

static ssize_t
devsock_write(struct Fd *fd, const void *buf, size_t n)
{
  8020f6:	55                   	push   %ebp
  8020f7:	89 e5                	mov    %esp,%ebp
  8020f9:	83 ec 18             	sub    $0x18,%esp
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
  8020fc:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  802103:	00 
  802104:	8b 45 10             	mov    0x10(%ebp),%eax
  802107:	89 44 24 08          	mov    %eax,0x8(%esp)
  80210b:	8b 45 0c             	mov    0xc(%ebp),%eax
  80210e:	89 44 24 04          	mov    %eax,0x4(%esp)
  802112:	8b 45 08             	mov    0x8(%ebp),%eax
  802115:	8b 40 0c             	mov    0xc(%eax),%eax
  802118:	89 04 24             	mov    %eax,(%esp)
  80211b:	e8 ad 02 00 00       	call   8023cd <nsipc_send>
}
  802120:	c9                   	leave  
  802121:	c3                   	ret    

00802122 <devsock_read>:
	return nsipc_listen(r, backlog);
}

static ssize_t
devsock_read(struct Fd *fd, void *buf, size_t n)
{
  802122:	55                   	push   %ebp
  802123:	89 e5                	mov    %esp,%ebp
  802125:	83 ec 18             	sub    $0x18,%esp
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
  802128:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80212f:	00 
  802130:	8b 45 10             	mov    0x10(%ebp),%eax
  802133:	89 44 24 08          	mov    %eax,0x8(%esp)
  802137:	8b 45 0c             	mov    0xc(%ebp),%eax
  80213a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80213e:	8b 45 08             	mov    0x8(%ebp),%eax
  802141:	8b 40 0c             	mov    0xc(%eax),%eax
  802144:	89 04 24             	mov    %eax,(%esp)
  802147:	e8 f4 02 00 00       	call   802440 <nsipc_recv>
}
  80214c:	c9                   	leave  
  80214d:	c3                   	ret    

0080214e <alloc_sockfd>:
	return sfd->fd_sock.sockid;
}

static int
alloc_sockfd(int sockid)
{
  80214e:	55                   	push   %ebp
  80214f:	89 e5                	mov    %esp,%ebp
  802151:	56                   	push   %esi
  802152:	53                   	push   %ebx
  802153:	83 ec 20             	sub    $0x20,%esp
  802156:	89 c6                	mov    %eax,%esi
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  802158:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80215b:	89 04 24             	mov    %eax,(%esp)
  80215e:	e8 68 f6 ff ff       	call   8017cb <fd_alloc>
  802163:	89 c3                	mov    %eax,%ebx
  802165:	85 c0                	test   %eax,%eax
  802167:	78 21                	js     80218a <alloc_sockfd+0x3c>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
  802169:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802170:	00 
  802171:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802174:	89 44 24 04          	mov    %eax,0x4(%esp)
  802178:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80217f:	e8 f2 f0 ff ff       	call   801276 <sys_page_alloc>
  802184:	89 c3                	mov    %eax,%ebx
alloc_sockfd(int sockid)
{
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  802186:	85 c0                	test   %eax,%eax
  802188:	79 0a                	jns    802194 <alloc_sockfd+0x46>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
		nsipc_close(sockid);
  80218a:	89 34 24             	mov    %esi,(%esp)
  80218d:	e8 ff 01 00 00       	call   802391 <nsipc_close>
		return r;
  802192:	eb 28                	jmp    8021bc <alloc_sockfd+0x6e>
	}

	sfd->fd_dev_id = devsock.dev_id;
  802194:	8b 15 24 70 80 00    	mov    0x807024,%edx
  80219a:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80219d:	89 10                	mov    %edx,(%eax)
	sfd->fd_omode = O_RDWR;
  80219f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8021a2:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	sfd->fd_sock.sockid = sockid;
  8021a9:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8021ac:	89 70 0c             	mov    %esi,0xc(%eax)
	return fd2num(sfd);
  8021af:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8021b2:	89 04 24             	mov    %eax,(%esp)
  8021b5:	e8 e6 f5 ff ff       	call   8017a0 <fd2num>
  8021ba:	89 c3                	mov    %eax,%ebx
}
  8021bc:	89 d8                	mov    %ebx,%eax
  8021be:	83 c4 20             	add    $0x20,%esp
  8021c1:	5b                   	pop    %ebx
  8021c2:	5e                   	pop    %esi
  8021c3:	5d                   	pop    %ebp
  8021c4:	c3                   	ret    

008021c5 <socket>:
	return 0;
}

int
socket(int domain, int type, int protocol)
{
  8021c5:	55                   	push   %ebp
  8021c6:	89 e5                	mov    %esp,%ebp
  8021c8:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = nsipc_socket(domain, type, protocol)) < 0)
  8021cb:	8b 45 10             	mov    0x10(%ebp),%eax
  8021ce:	89 44 24 08          	mov    %eax,0x8(%esp)
  8021d2:	8b 45 0c             	mov    0xc(%ebp),%eax
  8021d5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8021d9:	8b 45 08             	mov    0x8(%ebp),%eax
  8021dc:	89 04 24             	mov    %eax,(%esp)
  8021df:	e8 61 01 00 00       	call   802345 <nsipc_socket>
  8021e4:	85 c0                	test   %eax,%eax
  8021e6:	78 05                	js     8021ed <socket+0x28>
		return r;
	return alloc_sockfd(r);
  8021e8:	e8 61 ff ff ff       	call   80214e <alloc_sockfd>
}
  8021ed:	c9                   	leave  
  8021ee:	66 90                	xchg   %ax,%ax
  8021f0:	c3                   	ret    

008021f1 <fd2sockid>:
	.dev_stat =	devsock_stat,
};

static int
fd2sockid(int fd)
{
  8021f1:	55                   	push   %ebp
  8021f2:	89 e5                	mov    %esp,%ebp
  8021f4:	83 ec 28             	sub    $0x28,%esp
	struct Fd *sfd;
	int r;

	if ((r = fd_lookup(fd, &sfd)) < 0)
  8021f7:	8d 55 f4             	lea    -0xc(%ebp),%edx
  8021fa:	89 54 24 04          	mov    %edx,0x4(%esp)
  8021fe:	89 04 24             	mov    %eax,(%esp)
  802201:	e8 37 f6 ff ff       	call   80183d <fd_lookup>
  802206:	85 c0                	test   %eax,%eax
  802208:	78 15                	js     80221f <fd2sockid+0x2e>
		return r;
	if (sfd->fd_dev_id != devsock.dev_id)
  80220a:	8b 55 f4             	mov    -0xc(%ebp),%edx
  80220d:	8b 0a                	mov    (%edx),%ecx
  80220f:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  802214:	3b 0d 24 70 80 00    	cmp    0x807024,%ecx
  80221a:	75 03                	jne    80221f <fd2sockid+0x2e>
		return -E_NOT_SUPP;
	return sfd->fd_sock.sockid;
  80221c:	8b 42 0c             	mov    0xc(%edx),%eax
}
  80221f:	c9                   	leave  
  802220:	c3                   	ret    

00802221 <listen>:
	return nsipc_connect(r, name, namelen);
}

int
listen(int s, int backlog)
{
  802221:	55                   	push   %ebp
  802222:	89 e5                	mov    %esp,%ebp
  802224:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802227:	8b 45 08             	mov    0x8(%ebp),%eax
  80222a:	e8 c2 ff ff ff       	call   8021f1 <fd2sockid>
  80222f:	85 c0                	test   %eax,%eax
  802231:	78 0f                	js     802242 <listen+0x21>
		return r;
	return nsipc_listen(r, backlog);
  802233:	8b 55 0c             	mov    0xc(%ebp),%edx
  802236:	89 54 24 04          	mov    %edx,0x4(%esp)
  80223a:	89 04 24             	mov    %eax,(%esp)
  80223d:	e8 2d 01 00 00       	call   80236f <nsipc_listen>
}
  802242:	c9                   	leave  
  802243:	c3                   	ret    

00802244 <connect>:
	return nsipc_close(fd->fd_sock.sockid);
}

int
connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  802244:	55                   	push   %ebp
  802245:	89 e5                	mov    %esp,%ebp
  802247:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  80224a:	8b 45 08             	mov    0x8(%ebp),%eax
  80224d:	e8 9f ff ff ff       	call   8021f1 <fd2sockid>
  802252:	85 c0                	test   %eax,%eax
  802254:	78 16                	js     80226c <connect+0x28>
		return r;
	return nsipc_connect(r, name, namelen);
  802256:	8b 55 10             	mov    0x10(%ebp),%edx
  802259:	89 54 24 08          	mov    %edx,0x8(%esp)
  80225d:	8b 55 0c             	mov    0xc(%ebp),%edx
  802260:	89 54 24 04          	mov    %edx,0x4(%esp)
  802264:	89 04 24             	mov    %eax,(%esp)
  802267:	e8 54 02 00 00       	call   8024c0 <nsipc_connect>
}
  80226c:	c9                   	leave  
  80226d:	c3                   	ret    

0080226e <shutdown>:
	return nsipc_bind(r, name, namelen);
}

int
shutdown(int s, int how)
{
  80226e:	55                   	push   %ebp
  80226f:	89 e5                	mov    %esp,%ebp
  802271:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802274:	8b 45 08             	mov    0x8(%ebp),%eax
  802277:	e8 75 ff ff ff       	call   8021f1 <fd2sockid>
  80227c:	85 c0                	test   %eax,%eax
  80227e:	78 0f                	js     80228f <shutdown+0x21>
		return r;
	return nsipc_shutdown(r, how);
  802280:	8b 55 0c             	mov    0xc(%ebp),%edx
  802283:	89 54 24 04          	mov    %edx,0x4(%esp)
  802287:	89 04 24             	mov    %eax,(%esp)
  80228a:	e8 1c 01 00 00       	call   8023ab <nsipc_shutdown>
}
  80228f:	c9                   	leave  
  802290:	c3                   	ret    

00802291 <bind>:
	return alloc_sockfd(r);
}

int
bind(int s, struct sockaddr *name, socklen_t namelen)
{
  802291:	55                   	push   %ebp
  802292:	89 e5                	mov    %esp,%ebp
  802294:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802297:	8b 45 08             	mov    0x8(%ebp),%eax
  80229a:	e8 52 ff ff ff       	call   8021f1 <fd2sockid>
  80229f:	85 c0                	test   %eax,%eax
  8022a1:	78 16                	js     8022b9 <bind+0x28>
		return r;
	return nsipc_bind(r, name, namelen);
  8022a3:	8b 55 10             	mov    0x10(%ebp),%edx
  8022a6:	89 54 24 08          	mov    %edx,0x8(%esp)
  8022aa:	8b 55 0c             	mov    0xc(%ebp),%edx
  8022ad:	89 54 24 04          	mov    %edx,0x4(%esp)
  8022b1:	89 04 24             	mov    %eax,(%esp)
  8022b4:	e8 46 02 00 00       	call   8024ff <nsipc_bind>
}
  8022b9:	c9                   	leave  
  8022ba:	c3                   	ret    

008022bb <accept>:
	return fd2num(sfd);
}

int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  8022bb:	55                   	push   %ebp
  8022bc:	89 e5                	mov    %esp,%ebp
  8022be:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  8022c1:	8b 45 08             	mov    0x8(%ebp),%eax
  8022c4:	e8 28 ff ff ff       	call   8021f1 <fd2sockid>
  8022c9:	85 c0                	test   %eax,%eax
  8022cb:	78 1f                	js     8022ec <accept+0x31>
		return r;
	if ((r = nsipc_accept(r, addr, addrlen)) < 0)
  8022cd:	8b 55 10             	mov    0x10(%ebp),%edx
  8022d0:	89 54 24 08          	mov    %edx,0x8(%esp)
  8022d4:	8b 55 0c             	mov    0xc(%ebp),%edx
  8022d7:	89 54 24 04          	mov    %edx,0x4(%esp)
  8022db:	89 04 24             	mov    %eax,(%esp)
  8022de:	e8 5b 02 00 00       	call   80253e <nsipc_accept>
  8022e3:	85 c0                	test   %eax,%eax
  8022e5:	78 05                	js     8022ec <accept+0x31>
		return r;
	return alloc_sockfd(r);
  8022e7:	e8 62 fe ff ff       	call   80214e <alloc_sockfd>
}
  8022ec:	c9                   	leave  
  8022ed:	8d 76 00             	lea    0x0(%esi),%esi
  8022f0:	c3                   	ret    
	...

00802300 <nsipc>:
// may be written back to nsipcbuf.
// type: request code, passed as the simple integer IPC value.
// Returns 0 if successful, < 0 on failure.
static int
nsipc(unsigned type)
{
  802300:	55                   	push   %ebp
  802301:	89 e5                	mov    %esp,%ebp
  802303:	83 ec 28             	sub    $0x28,%esp
    int r=0;
    envid_t from;
	if (debug)
		cprintf("[%08x] nsipc %d\n", env->env_id, type);

	ipc_send(envs[2].env_id, type, &nsipcbuf, PTE_P|PTE_W|PTE_U);
  802306:	8b 15 44 01 c0 ee    	mov    0xeec00144,%edx
  80230c:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  802313:	00 
  802314:	c7 44 24 08 00 60 80 	movl   $0x806000,0x8(%esp)
  80231b:	00 
  80231c:	89 44 24 04          	mov    %eax,0x4(%esp)
  802320:	89 14 24             	mov    %edx,(%esp)
  802323:	e8 08 09 00 00       	call   802c30 <ipc_send>
	r=ipc_recv(&from, NULL, NULL);
  802328:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80232f:	00 
  802330:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  802337:	00 
  802338:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80233b:	89 04 24             	mov    %eax,(%esp)
  80233e:	e8 5f 09 00 00       	call   802ca2 <ipc_recv>
    return r;
}
  802343:	c9                   	leave  
  802344:	c3                   	ret    

00802345 <nsipc_socket>:
	return nsipc(NSREQ_SEND);
}

int
nsipc_socket(int domain, int type, int protocol)
{
  802345:	55                   	push   %ebp
  802346:	89 e5                	mov    %esp,%ebp
  802348:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.socket.req_domain = domain;
  80234b:	8b 45 08             	mov    0x8(%ebp),%eax
  80234e:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.socket.req_type = type;
  802353:	8b 45 0c             	mov    0xc(%ebp),%eax
  802356:	a3 04 60 80 00       	mov    %eax,0x806004
	nsipcbuf.socket.req_protocol = protocol;
  80235b:	8b 45 10             	mov    0x10(%ebp),%eax
  80235e:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SOCKET);
  802363:	b8 09 00 00 00       	mov    $0x9,%eax
  802368:	e8 93 ff ff ff       	call   802300 <nsipc>
}
  80236d:	c9                   	leave  
  80236e:	c3                   	ret    

0080236f <nsipc_listen>:
	return nsipc(NSREQ_CONNECT);
}

int
nsipc_listen(int s, int backlog)
{
  80236f:	55                   	push   %ebp
  802370:	89 e5                	mov    %esp,%ebp
  802372:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.listen.req_s = s;
  802375:	8b 45 08             	mov    0x8(%ebp),%eax
  802378:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.listen.req_backlog = backlog;
  80237d:	8b 45 0c             	mov    0xc(%ebp),%eax
  802380:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_LISTEN);
  802385:	b8 06 00 00 00       	mov    $0x6,%eax
  80238a:	e8 71 ff ff ff       	call   802300 <nsipc>
}
  80238f:	c9                   	leave  
  802390:	c3                   	ret    

00802391 <nsipc_close>:
	return nsipc(NSREQ_SHUTDOWN);
}

int
nsipc_close(int s)
{
  802391:	55                   	push   %ebp
  802392:	89 e5                	mov    %esp,%ebp
  802394:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.close.req_s = s;
  802397:	8b 45 08             	mov    0x8(%ebp),%eax
  80239a:	a3 00 60 80 00       	mov    %eax,0x806000
	return nsipc(NSREQ_CLOSE);
  80239f:	b8 04 00 00 00       	mov    $0x4,%eax
  8023a4:	e8 57 ff ff ff       	call   802300 <nsipc>
}
  8023a9:	c9                   	leave  
  8023aa:	c3                   	ret    

008023ab <nsipc_shutdown>:
	return nsipc(NSREQ_BIND);
}

int
nsipc_shutdown(int s, int how)
{
  8023ab:	55                   	push   %ebp
  8023ac:	89 e5                	mov    %esp,%ebp
  8023ae:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.shutdown.req_s = s;
  8023b1:	8b 45 08             	mov    0x8(%ebp),%eax
  8023b4:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.shutdown.req_how = how;
  8023b9:	8b 45 0c             	mov    0xc(%ebp),%eax
  8023bc:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_SHUTDOWN);
  8023c1:	b8 03 00 00 00       	mov    $0x3,%eax
  8023c6:	e8 35 ff ff ff       	call   802300 <nsipc>
}
  8023cb:	c9                   	leave  
  8023cc:	c3                   	ret    

008023cd <nsipc_send>:
	return r;
}

int
nsipc_send(int s, const void *buf, int size, unsigned int flags)
{
  8023cd:	55                   	push   %ebp
  8023ce:	89 e5                	mov    %esp,%ebp
  8023d0:	53                   	push   %ebx
  8023d1:	83 ec 14             	sub    $0x14,%esp
  8023d4:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.send.req_s = s;
  8023d7:	8b 45 08             	mov    0x8(%ebp),%eax
  8023da:	a3 00 60 80 00       	mov    %eax,0x806000
	assert(size < 1600);
  8023df:	81 fb 3f 06 00 00    	cmp    $0x63f,%ebx
  8023e5:	7e 24                	jle    80240b <nsipc_send+0x3e>
  8023e7:	c7 44 24 0c d4 36 80 	movl   $0x8036d4,0xc(%esp)
  8023ee:	00 
  8023ef:	c7 44 24 08 e0 36 80 	movl   $0x8036e0,0x8(%esp)
  8023f6:	00 
  8023f7:	c7 44 24 04 69 00 00 	movl   $0x69,0x4(%esp)
  8023fe:	00 
  8023ff:	c7 04 24 f5 36 80 00 	movl   $0x8036f5,(%esp)
  802406:	e8 79 df ff ff       	call   800384 <_panic>
	memmove(&nsipcbuf.send.req_buf, buf, size);
  80240b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  80240f:	8b 45 0c             	mov    0xc(%ebp),%eax
  802412:	89 44 24 04          	mov    %eax,0x4(%esp)
  802416:	c7 04 24 0c 60 80 00 	movl   $0x80600c,(%esp)
  80241d:	e8 b3 e8 ff ff       	call   800cd5 <memmove>
	nsipcbuf.send.req_size = size;
  802422:	89 1d 04 60 80 00    	mov    %ebx,0x806004
	nsipcbuf.send.req_flags = flags;
  802428:	8b 45 14             	mov    0x14(%ebp),%eax
  80242b:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SEND);
  802430:	b8 08 00 00 00       	mov    $0x8,%eax
  802435:	e8 c6 fe ff ff       	call   802300 <nsipc>
}
  80243a:	83 c4 14             	add    $0x14,%esp
  80243d:	5b                   	pop    %ebx
  80243e:	5d                   	pop    %ebp
  80243f:	c3                   	ret    

00802440 <nsipc_recv>:
	return nsipc(NSREQ_LISTEN);
}

int
nsipc_recv(int s, void *mem, int len, unsigned int flags)
{
  802440:	55                   	push   %ebp
  802441:	89 e5                	mov    %esp,%ebp
  802443:	56                   	push   %esi
  802444:	53                   	push   %ebx
  802445:	83 ec 10             	sub    $0x10,%esp
  802448:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;

	nsipcbuf.recv.req_s = s;
  80244b:	8b 45 08             	mov    0x8(%ebp),%eax
  80244e:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.recv.req_len = len;
  802453:	89 35 04 60 80 00    	mov    %esi,0x806004
	nsipcbuf.recv.req_flags = flags;
  802459:	8b 45 14             	mov    0x14(%ebp),%eax
  80245c:	a3 08 60 80 00       	mov    %eax,0x806008

	if ((r = nsipc(NSREQ_RECV)) >= 0) {
  802461:	b8 07 00 00 00       	mov    $0x7,%eax
  802466:	e8 95 fe ff ff       	call   802300 <nsipc>
  80246b:	89 c3                	mov    %eax,%ebx
  80246d:	85 c0                	test   %eax,%eax
  80246f:	78 46                	js     8024b7 <nsipc_recv+0x77>
		assert(r < 1600 && r <= len);
  802471:	3d 3f 06 00 00       	cmp    $0x63f,%eax
  802476:	7f 04                	jg     80247c <nsipc_recv+0x3c>
  802478:	39 c6                	cmp    %eax,%esi
  80247a:	7d 24                	jge    8024a0 <nsipc_recv+0x60>
  80247c:	c7 44 24 0c 01 37 80 	movl   $0x803701,0xc(%esp)
  802483:	00 
  802484:	c7 44 24 08 e0 36 80 	movl   $0x8036e0,0x8(%esp)
  80248b:	00 
  80248c:	c7 44 24 04 5e 00 00 	movl   $0x5e,0x4(%esp)
  802493:	00 
  802494:	c7 04 24 f5 36 80 00 	movl   $0x8036f5,(%esp)
  80249b:	e8 e4 de ff ff       	call   800384 <_panic>
		memmove(mem, nsipcbuf.recvRet.ret_buf, r);
  8024a0:	89 44 24 08          	mov    %eax,0x8(%esp)
  8024a4:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  8024ab:	00 
  8024ac:	8b 45 0c             	mov    0xc(%ebp),%eax
  8024af:	89 04 24             	mov    %eax,(%esp)
  8024b2:	e8 1e e8 ff ff       	call   800cd5 <memmove>
	}

	return r;
}
  8024b7:	89 d8                	mov    %ebx,%eax
  8024b9:	83 c4 10             	add    $0x10,%esp
  8024bc:	5b                   	pop    %ebx
  8024bd:	5e                   	pop    %esi
  8024be:	5d                   	pop    %ebp
  8024bf:	c3                   	ret    

008024c0 <nsipc_connect>:
	return nsipc(NSREQ_CLOSE);
}

int
nsipc_connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  8024c0:	55                   	push   %ebp
  8024c1:	89 e5                	mov    %esp,%ebp
  8024c3:	53                   	push   %ebx
  8024c4:	83 ec 14             	sub    $0x14,%esp
  8024c7:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.connect.req_s = s;
  8024ca:	8b 45 08             	mov    0x8(%ebp),%eax
  8024cd:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.connect.req_name, name, namelen);
  8024d2:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8024d6:	8b 45 0c             	mov    0xc(%ebp),%eax
  8024d9:	89 44 24 04          	mov    %eax,0x4(%esp)
  8024dd:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  8024e4:	e8 ec e7 ff ff       	call   800cd5 <memmove>
	nsipcbuf.connect.req_namelen = namelen;
  8024e9:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_CONNECT);
  8024ef:	b8 05 00 00 00       	mov    $0x5,%eax
  8024f4:	e8 07 fe ff ff       	call   802300 <nsipc>
}
  8024f9:	83 c4 14             	add    $0x14,%esp
  8024fc:	5b                   	pop    %ebx
  8024fd:	5d                   	pop    %ebp
  8024fe:	c3                   	ret    

008024ff <nsipc_bind>:
	return r;
}

int
nsipc_bind(int s, struct sockaddr *name, socklen_t namelen)
{
  8024ff:	55                   	push   %ebp
  802500:	89 e5                	mov    %esp,%ebp
  802502:	53                   	push   %ebx
  802503:	83 ec 14             	sub    $0x14,%esp
  802506:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.bind.req_s = s;
  802509:	8b 45 08             	mov    0x8(%ebp),%eax
  80250c:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.bind.req_name, name, namelen);
  802511:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802515:	8b 45 0c             	mov    0xc(%ebp),%eax
  802518:	89 44 24 04          	mov    %eax,0x4(%esp)
  80251c:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  802523:	e8 ad e7 ff ff       	call   800cd5 <memmove>
	nsipcbuf.bind.req_namelen = namelen;
  802528:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_BIND);
  80252e:	b8 02 00 00 00       	mov    $0x2,%eax
  802533:	e8 c8 fd ff ff       	call   802300 <nsipc>
}
  802538:	83 c4 14             	add    $0x14,%esp
  80253b:	5b                   	pop    %ebx
  80253c:	5d                   	pop    %ebp
  80253d:	c3                   	ret    

0080253e <nsipc_accept>:
    return r;
}

int
nsipc_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  80253e:	55                   	push   %ebp
  80253f:	89 e5                	mov    %esp,%ebp
  802541:	83 ec 18             	sub    $0x18,%esp
  802544:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802547:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int r;
	
	nsipcbuf.accept.req_s = s;
  80254a:	8b 45 08             	mov    0x8(%ebp),%eax
  80254d:	a3 00 60 80 00       	mov    %eax,0x806000
	if ((r = nsipc(NSREQ_ACCEPT)) >= 0) {
  802552:	b8 01 00 00 00       	mov    $0x1,%eax
  802557:	e8 a4 fd ff ff       	call   802300 <nsipc>
  80255c:	89 c3                	mov    %eax,%ebx
  80255e:	85 c0                	test   %eax,%eax
  802560:	78 25                	js     802587 <nsipc_accept+0x49>
		struct Nsret_accept *ret = &nsipcbuf.acceptRet;
		memmove(addr, &ret->ret_addr, ret->ret_addrlen);
  802562:	be 10 60 80 00       	mov    $0x806010,%esi
  802567:	8b 06                	mov    (%esi),%eax
  802569:	89 44 24 08          	mov    %eax,0x8(%esp)
  80256d:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  802574:	00 
  802575:	8b 45 0c             	mov    0xc(%ebp),%eax
  802578:	89 04 24             	mov    %eax,(%esp)
  80257b:	e8 55 e7 ff ff       	call   800cd5 <memmove>
		*addrlen = ret->ret_addrlen;
  802580:	8b 16                	mov    (%esi),%edx
  802582:	8b 45 10             	mov    0x10(%ebp),%eax
  802585:	89 10                	mov    %edx,(%eax)
	}
	return r;
}
  802587:	89 d8                	mov    %ebx,%eax
  802589:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80258c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80258f:	89 ec                	mov    %ebp,%esp
  802591:	5d                   	pop    %ebp
  802592:	c3                   	ret    
	...

008025a0 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  8025a0:	55                   	push   %ebp
  8025a1:	89 e5                	mov    %esp,%ebp
  8025a3:	83 ec 18             	sub    $0x18,%esp
  8025a6:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8025a9:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8025ac:	8b 75 0c             	mov    0xc(%ebp),%esi
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  8025af:	8b 45 08             	mov    0x8(%ebp),%eax
  8025b2:	89 04 24             	mov    %eax,(%esp)
  8025b5:	e8 f6 f1 ff ff       	call   8017b0 <fd2data>
  8025ba:	89 c3                	mov    %eax,%ebx
	strcpy(stat->st_name, "<pipe>");
  8025bc:	c7 44 24 04 16 37 80 	movl   $0x803716,0x4(%esp)
  8025c3:	00 
  8025c4:	89 34 24             	mov    %esi,(%esp)
  8025c7:	e8 4e e5 ff ff       	call   800b1a <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  8025cc:	8b 43 04             	mov    0x4(%ebx),%eax
  8025cf:	2b 03                	sub    (%ebx),%eax
  8025d1:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
	stat->st_isdir = 0;
  8025d7:	c7 86 84 00 00 00 00 	movl   $0x0,0x84(%esi)
  8025de:	00 00 00 
	stat->st_dev = &devpipe;
  8025e1:	c7 86 88 00 00 00 40 	movl   $0x807040,0x88(%esi)
  8025e8:	70 80 00 
	return 0;
}
  8025eb:	b8 00 00 00 00       	mov    $0x0,%eax
  8025f0:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8025f3:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8025f6:	89 ec                	mov    %ebp,%esp
  8025f8:	5d                   	pop    %ebp
  8025f9:	c3                   	ret    

008025fa <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  8025fa:	55                   	push   %ebp
  8025fb:	89 e5                	mov    %esp,%ebp
  8025fd:	53                   	push   %ebx
  8025fe:	83 ec 14             	sub    $0x14,%esp
  802601:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  802604:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802608:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80260f:	e8 a6 eb ff ff       	call   8011ba <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  802614:	89 1c 24             	mov    %ebx,(%esp)
  802617:	e8 94 f1 ff ff       	call   8017b0 <fd2data>
  80261c:	89 44 24 04          	mov    %eax,0x4(%esp)
  802620:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802627:	e8 8e eb ff ff       	call   8011ba <sys_page_unmap>
}
  80262c:	83 c4 14             	add    $0x14,%esp
  80262f:	5b                   	pop    %ebx
  802630:	5d                   	pop    %ebp
  802631:	c3                   	ret    

00802632 <_pipeisclosed>:
	return r;
}

static int
_pipeisclosed(struct Fd *fd, struct Pipe *p)
{
  802632:	55                   	push   %ebp
  802633:	89 e5                	mov    %esp,%ebp
  802635:	57                   	push   %edi
  802636:	56                   	push   %esi
  802637:	53                   	push   %ebx
  802638:	83 ec 2c             	sub    $0x2c,%esp
  80263b:	89 c7                	mov    %eax,%edi
  80263d:	89 55 e4             	mov    %edx,-0x1c(%ebp)
	int n, nn, ret;

	while (1) {
		n = env->env_runs;
  802640:	a1 78 70 80 00       	mov    0x807078,%eax
  802645:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  802648:	89 3c 24             	mov    %edi,(%esp)
  80264b:	e8 a4 06 00 00       	call   802cf4 <pageref>
  802650:	89 c6                	mov    %eax,%esi
  802652:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802655:	89 04 24             	mov    %eax,(%esp)
  802658:	e8 97 06 00 00       	call   802cf4 <pageref>
  80265d:	39 c6                	cmp    %eax,%esi
  80265f:	0f 94 c0             	sete   %al
  802662:	0f b6 c0             	movzbl %al,%eax
		nn = env->env_runs;
  802665:	8b 15 78 70 80 00    	mov    0x807078,%edx
  80266b:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  80266e:	39 cb                	cmp    %ecx,%ebx
  802670:	75 08                	jne    80267a <_pipeisclosed+0x48>
			return ret;
		if (n != nn && ret == 1)
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
	}
}
  802672:	83 c4 2c             	add    $0x2c,%esp
  802675:	5b                   	pop    %ebx
  802676:	5e                   	pop    %esi
  802677:	5f                   	pop    %edi
  802678:	5d                   	pop    %ebp
  802679:	c3                   	ret    
		n = env->env_runs;
		ret = pageref(fd) == pageref(p);
		nn = env->env_runs;
		if (n == nn)
			return ret;
		if (n != nn && ret == 1)
  80267a:	83 f8 01             	cmp    $0x1,%eax
  80267d:	75 c1                	jne    802640 <_pipeisclosed+0xe>
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
  80267f:	8b 52 58             	mov    0x58(%edx),%edx
  802682:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802686:	89 54 24 08          	mov    %edx,0x8(%esp)
  80268a:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80268e:	c7 04 24 1d 37 80 00 	movl   $0x80371d,(%esp)
  802695:	e8 af dd ff ff       	call   800449 <cprintf>
  80269a:	eb a4                	jmp    802640 <_pipeisclosed+0xe>

0080269c <devpipe_write>:
	return i;
}

static ssize_t
devpipe_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80269c:	55                   	push   %ebp
  80269d:	89 e5                	mov    %esp,%ebp
  80269f:	57                   	push   %edi
  8026a0:	56                   	push   %esi
  8026a1:	53                   	push   %ebx
  8026a2:	83 ec 1c             	sub    $0x1c,%esp
  8026a5:	8b 75 08             	mov    0x8(%ebp),%esi
	const uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*) fd2data(fd);
  8026a8:	89 34 24             	mov    %esi,(%esp)
  8026ab:	e8 00 f1 ff ff       	call   8017b0 <fd2data>
  8026b0:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  8026b2:	bf 00 00 00 00       	mov    $0x0,%edi
  8026b7:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  8026bb:	75 54                	jne    802711 <devpipe_write+0x75>
  8026bd:	eb 60                	jmp    80271f <devpipe_write+0x83>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
			// pipe is full
			// if all the readers are gone
			// (it's only writers like us now),
			// note eof
			if (_pipeisclosed(fd, p))
  8026bf:	89 da                	mov    %ebx,%edx
  8026c1:	89 f0                	mov    %esi,%eax
  8026c3:	e8 6a ff ff ff       	call   802632 <_pipeisclosed>
  8026c8:	85 c0                	test   %eax,%eax
  8026ca:	74 07                	je     8026d3 <devpipe_write+0x37>
  8026cc:	b8 00 00 00 00       	mov    $0x0,%eax
  8026d1:	eb 53                	jmp    802726 <devpipe_write+0x8a>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_write yield\n");
			sys_yield();
  8026d3:	90                   	nop
  8026d4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8026d8:	e8 f8 eb ff ff       	call   8012d5 <sys_yield>
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  8026dd:	8b 43 04             	mov    0x4(%ebx),%eax
  8026e0:	8b 13                	mov    (%ebx),%edx
  8026e2:	83 c2 20             	add    $0x20,%edx
  8026e5:	39 d0                	cmp    %edx,%eax
  8026e7:	73 d6                	jae    8026bf <devpipe_write+0x23>
				cprintf("devpipe_write yield\n");
			sys_yield();
		}
		// there's room for a byte.  store it.
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  8026e9:	89 c2                	mov    %eax,%edx
  8026eb:	c1 fa 1f             	sar    $0x1f,%edx
  8026ee:	c1 ea 1b             	shr    $0x1b,%edx
  8026f1:	01 d0                	add    %edx,%eax
  8026f3:	83 e0 1f             	and    $0x1f,%eax
  8026f6:	29 d0                	sub    %edx,%eax
  8026f8:	89 c2                	mov    %eax,%edx
  8026fa:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8026fd:	0f b6 04 39          	movzbl (%ecx,%edi,1),%eax
  802701:	88 44 13 08          	mov    %al,0x8(%ebx,%edx,1)
		p->p_wpos++;
  802705:	83 43 04 01          	addl   $0x1,0x4(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802709:	83 c7 01             	add    $0x1,%edi
  80270c:	39 7d 10             	cmp    %edi,0x10(%ebp)
  80270f:	76 13                	jbe    802724 <devpipe_write+0x88>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  802711:	8b 43 04             	mov    0x4(%ebx),%eax
  802714:	8b 13                	mov    (%ebx),%edx
  802716:	83 c2 20             	add    $0x20,%edx
  802719:	39 d0                	cmp    %edx,%eax
  80271b:	73 a2                	jae    8026bf <devpipe_write+0x23>
  80271d:	eb ca                	jmp    8026e9 <devpipe_write+0x4d>
  80271f:	bf 00 00 00 00       	mov    $0x0,%edi
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
		p->p_wpos++;
	}
	
	return i;
  802724:	89 f8                	mov    %edi,%eax
}
  802726:	83 c4 1c             	add    $0x1c,%esp
  802729:	5b                   	pop    %ebx
  80272a:	5e                   	pop    %esi
  80272b:	5f                   	pop    %edi
  80272c:	5d                   	pop    %ebp
  80272d:	c3                   	ret    

0080272e <devpipe_read>:
	return _pipeisclosed(fd, p);
}

static ssize_t
devpipe_read(struct Fd *fd, void *vbuf, size_t n)
{
  80272e:	55                   	push   %ebp
  80272f:	89 e5                	mov    %esp,%ebp
  802731:	83 ec 28             	sub    $0x28,%esp
  802734:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802737:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80273a:	89 7d fc             	mov    %edi,-0x4(%ebp)
  80273d:	8b 7d 08             	mov    0x8(%ebp),%edi
	uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*)fd2data(fd);
  802740:	89 3c 24             	mov    %edi,(%esp)
  802743:	e8 68 f0 ff ff       	call   8017b0 <fd2data>
  802748:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  80274a:	be 00 00 00 00       	mov    $0x0,%esi
  80274f:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802753:	75 4c                	jne    8027a1 <devpipe_read+0x73>
  802755:	eb 5b                	jmp    8027b2 <devpipe_read+0x84>
		while (p->p_rpos == p->p_wpos) {
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
				return i;
  802757:	89 f0                	mov    %esi,%eax
  802759:	eb 5e                	jmp    8027b9 <devpipe_read+0x8b>
			// if all the writers are gone, note eof
			if (_pipeisclosed(fd, p))
  80275b:	89 da                	mov    %ebx,%edx
  80275d:	89 f8                	mov    %edi,%eax
  80275f:	90                   	nop
  802760:	e8 cd fe ff ff       	call   802632 <_pipeisclosed>
  802765:	85 c0                	test   %eax,%eax
  802767:	74 07                	je     802770 <devpipe_read+0x42>
  802769:	b8 00 00 00 00       	mov    $0x0,%eax
  80276e:	eb 49                	jmp    8027b9 <devpipe_read+0x8b>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_read yield\n");
			sys_yield();
  802770:	e8 60 eb ff ff       	call   8012d5 <sys_yield>
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_rpos == p->p_wpos) {
  802775:	8b 03                	mov    (%ebx),%eax
  802777:	3b 43 04             	cmp    0x4(%ebx),%eax
  80277a:	74 df                	je     80275b <devpipe_read+0x2d>
				cprintf("devpipe_read yield\n");
			sys_yield();
		}
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  80277c:	89 c2                	mov    %eax,%edx
  80277e:	c1 fa 1f             	sar    $0x1f,%edx
  802781:	c1 ea 1b             	shr    $0x1b,%edx
  802784:	01 d0                	add    %edx,%eax
  802786:	83 e0 1f             	and    $0x1f,%eax
  802789:	29 d0                	sub    %edx,%eax
  80278b:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  802790:	8b 55 0c             	mov    0xc(%ebp),%edx
  802793:	88 04 32             	mov    %al,(%edx,%esi,1)
		p->p_rpos++;
  802796:	83 03 01             	addl   $0x1,(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802799:	83 c6 01             	add    $0x1,%esi
  80279c:	39 75 10             	cmp    %esi,0x10(%ebp)
  80279f:	76 16                	jbe    8027b7 <devpipe_read+0x89>
		while (p->p_rpos == p->p_wpos) {
  8027a1:	8b 03                	mov    (%ebx),%eax
  8027a3:	3b 43 04             	cmp    0x4(%ebx),%eax
  8027a6:	75 d4                	jne    80277c <devpipe_read+0x4e>
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
  8027a8:	85 f6                	test   %esi,%esi
  8027aa:	75 ab                	jne    802757 <devpipe_read+0x29>
  8027ac:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8027b0:	eb a9                	jmp    80275b <devpipe_read+0x2d>
  8027b2:	be 00 00 00 00       	mov    $0x0,%esi
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
		p->p_rpos++;
	}
	return i;
  8027b7:	89 f0                	mov    %esi,%eax
}
  8027b9:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8027bc:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8027bf:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8027c2:	89 ec                	mov    %ebp,%esp
  8027c4:	5d                   	pop    %ebp
  8027c5:	c3                   	ret    

008027c6 <pipeisclosed>:
	}
}

int
pipeisclosed(int fdnum)
{
  8027c6:	55                   	push   %ebp
  8027c7:	89 e5                	mov    %esp,%ebp
  8027c9:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	struct Pipe *p;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8027cc:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8027cf:	89 44 24 04          	mov    %eax,0x4(%esp)
  8027d3:	8b 45 08             	mov    0x8(%ebp),%eax
  8027d6:	89 04 24             	mov    %eax,(%esp)
  8027d9:	e8 5f f0 ff ff       	call   80183d <fd_lookup>
  8027de:	85 c0                	test   %eax,%eax
  8027e0:	78 15                	js     8027f7 <pipeisclosed+0x31>
		return r;
	p = (struct Pipe*) fd2data(fd);
  8027e2:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8027e5:	89 04 24             	mov    %eax,(%esp)
  8027e8:	e8 c3 ef ff ff       	call   8017b0 <fd2data>
	return _pipeisclosed(fd, p);
  8027ed:	89 c2                	mov    %eax,%edx
  8027ef:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8027f2:	e8 3b fe ff ff       	call   802632 <_pipeisclosed>
}
  8027f7:	c9                   	leave  
  8027f8:	c3                   	ret    

008027f9 <pipe>:
	uint8_t p_buf[PIPEBUFSIZ];	// data buffer
};

int
pipe(int pfd[2])
{
  8027f9:	55                   	push   %ebp
  8027fa:	89 e5                	mov    %esp,%ebp
  8027fc:	83 ec 48             	sub    $0x48,%esp
  8027ff:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802802:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802805:	89 7d fc             	mov    %edi,-0x4(%ebp)
  802808:	8b 7d 08             	mov    0x8(%ebp),%edi
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  80280b:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  80280e:	89 04 24             	mov    %eax,(%esp)
  802811:	e8 b5 ef ff ff       	call   8017cb <fd_alloc>
  802816:	89 c3                	mov    %eax,%ebx
  802818:	85 c0                	test   %eax,%eax
  80281a:	0f 88 42 01 00 00    	js     802962 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802820:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802827:	00 
  802828:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80282b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80282f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802836:	e8 3b ea ff ff       	call   801276 <sys_page_alloc>
  80283b:	89 c3                	mov    %eax,%ebx
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  80283d:	85 c0                	test   %eax,%eax
  80283f:	0f 88 1d 01 00 00    	js     802962 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802845:	8d 45 e0             	lea    -0x20(%ebp),%eax
  802848:	89 04 24             	mov    %eax,(%esp)
  80284b:	e8 7b ef ff ff       	call   8017cb <fd_alloc>
  802850:	89 c3                	mov    %eax,%ebx
  802852:	85 c0                	test   %eax,%eax
  802854:	0f 88 f5 00 00 00    	js     80294f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80285a:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802861:	00 
  802862:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802865:	89 44 24 04          	mov    %eax,0x4(%esp)
  802869:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802870:	e8 01 ea ff ff       	call   801276 <sys_page_alloc>
  802875:	89 c3                	mov    %eax,%ebx
	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802877:	85 c0                	test   %eax,%eax
  802879:	0f 88 d0 00 00 00    	js     80294f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err1;

	// allocate the pipe structure as first data page in both
	va = fd2data(fd0);
  80287f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802882:	89 04 24             	mov    %eax,(%esp)
  802885:	e8 26 ef ff ff       	call   8017b0 <fd2data>
  80288a:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80288c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802893:	00 
  802894:	89 44 24 04          	mov    %eax,0x4(%esp)
  802898:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80289f:	e8 d2 e9 ff ff       	call   801276 <sys_page_alloc>
  8028a4:	89 c3                	mov    %eax,%ebx
  8028a6:	85 c0                	test   %eax,%eax
  8028a8:	0f 88 8e 00 00 00    	js     80293c <pipe+0x143>
		goto err2;
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  8028ae:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8028b1:	89 04 24             	mov    %eax,(%esp)
  8028b4:	e8 f7 ee ff ff       	call   8017b0 <fd2data>
  8028b9:	c7 44 24 10 07 04 00 	movl   $0x407,0x10(%esp)
  8028c0:	00 
  8028c1:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8028c5:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8028cc:	00 
  8028cd:	89 74 24 04          	mov    %esi,0x4(%esp)
  8028d1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8028d8:	e8 3b e9 ff ff       	call   801218 <sys_page_map>
  8028dd:	89 c3                	mov    %eax,%ebx
  8028df:	85 c0                	test   %eax,%eax
  8028e1:	78 49                	js     80292c <pipe+0x133>
		goto err3;

	// set up fd structures
	fd0->fd_dev_id = devpipe.dev_id;
  8028e3:	b8 40 70 80 00       	mov    $0x807040,%eax
  8028e8:	8b 08                	mov    (%eax),%ecx
  8028ea:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8028ed:	89 0a                	mov    %ecx,(%edx)
	fd0->fd_omode = O_RDONLY;
  8028ef:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8028f2:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)

	fd1->fd_dev_id = devpipe.dev_id;
  8028f9:	8b 10                	mov    (%eax),%edx
  8028fb:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8028fe:	89 10                	mov    %edx,(%eax)
	fd1->fd_omode = O_WRONLY;
  802900:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802903:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)

	if (debug)
		cprintf("[%08x] pipecreate %08x\n", env->env_id, vpt[VPN(va)]);

	pfd[0] = fd2num(fd0);
  80290a:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80290d:	89 04 24             	mov    %eax,(%esp)
  802910:	e8 8b ee ff ff       	call   8017a0 <fd2num>
  802915:	89 07                	mov    %eax,(%edi)
	pfd[1] = fd2num(fd1);
  802917:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80291a:	89 04 24             	mov    %eax,(%esp)
  80291d:	e8 7e ee ff ff       	call   8017a0 <fd2num>
  802922:	89 47 04             	mov    %eax,0x4(%edi)
  802925:	bb 00 00 00 00       	mov    $0x0,%ebx
	return 0;
  80292a:	eb 36                	jmp    802962 <pipe+0x169>

    err3:
	sys_page_unmap(0, va);
  80292c:	89 74 24 04          	mov    %esi,0x4(%esp)
  802930:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802937:	e8 7e e8 ff ff       	call   8011ba <sys_page_unmap>
    err2:
	sys_page_unmap(0, fd1);
  80293c:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80293f:	89 44 24 04          	mov    %eax,0x4(%esp)
  802943:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80294a:	e8 6b e8 ff ff       	call   8011ba <sys_page_unmap>
    err1:
	sys_page_unmap(0, fd0);
  80294f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802952:	89 44 24 04          	mov    %eax,0x4(%esp)
  802956:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80295d:	e8 58 e8 ff ff       	call   8011ba <sys_page_unmap>
    err:
	return r;
}
  802962:	89 d8                	mov    %ebx,%eax
  802964:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802967:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80296a:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80296d:	89 ec                	mov    %ebp,%esp
  80296f:	5d                   	pop    %ebp
  802970:	c3                   	ret    
  802971:	00 00                	add    %al,(%eax)
	...

00802974 <wait>:
#include <inc/lib.h>

// Waits until 'envid' exits.
void
wait(envid_t envid)
{
  802974:	55                   	push   %ebp
  802975:	89 e5                	mov    %esp,%ebp
  802977:	56                   	push   %esi
  802978:	53                   	push   %ebx
  802979:	83 ec 10             	sub    $0x10,%esp
  80297c:	8b 45 08             	mov    0x8(%ebp),%eax
	volatile struct Env *e;

	assert(envid != 0);
  80297f:	85 c0                	test   %eax,%eax
  802981:	75 24                	jne    8029a7 <wait+0x33>
  802983:	c7 44 24 0c 35 37 80 	movl   $0x803735,0xc(%esp)
  80298a:	00 
  80298b:	c7 44 24 08 e0 36 80 	movl   $0x8036e0,0x8(%esp)
  802992:	00 
  802993:	c7 44 24 04 09 00 00 	movl   $0x9,0x4(%esp)
  80299a:	00 
  80299b:	c7 04 24 40 37 80 00 	movl   $0x803740,(%esp)
  8029a2:	e8 dd d9 ff ff       	call   800384 <_panic>
	e = &envs[ENVX(envid)];
  8029a7:	89 c3                	mov    %eax,%ebx
  8029a9:	81 e3 ff 03 00 00    	and    $0x3ff,%ebx
  8029af:	6b db 7c             	imul   $0x7c,%ebx,%ebx
  8029b2:	81 c3 00 00 c0 ee    	add    $0xeec00000,%ebx
	while (e->env_id == envid && e->env_status != ENV_FREE)
  8029b8:	8b 73 4c             	mov    0x4c(%ebx),%esi
  8029bb:	39 c6                	cmp    %eax,%esi
  8029bd:	75 1a                	jne    8029d9 <wait+0x65>
  8029bf:	8b 43 54             	mov    0x54(%ebx),%eax
  8029c2:	85 c0                	test   %eax,%eax
  8029c4:	74 13                	je     8029d9 <wait+0x65>
		sys_yield();
  8029c6:	e8 0a e9 ff ff       	call   8012d5 <sys_yield>
{
	volatile struct Env *e;

	assert(envid != 0);
	e = &envs[ENVX(envid)];
	while (e->env_id == envid && e->env_status != ENV_FREE)
  8029cb:	8b 43 4c             	mov    0x4c(%ebx),%eax
  8029ce:	39 f0                	cmp    %esi,%eax
  8029d0:	75 07                	jne    8029d9 <wait+0x65>
  8029d2:	8b 43 54             	mov    0x54(%ebx),%eax
  8029d5:	85 c0                	test   %eax,%eax
  8029d7:	75 ed                	jne    8029c6 <wait+0x52>
		sys_yield();
}
  8029d9:	83 c4 10             	add    $0x10,%esp
  8029dc:	5b                   	pop    %ebx
  8029dd:	5e                   	pop    %esi
  8029de:	5d                   	pop    %ebp
  8029df:	c3                   	ret    

008029e0 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  8029e0:	55                   	push   %ebp
  8029e1:	89 e5                	mov    %esp,%ebp
	USED(fd);

	return 0;
}
  8029e3:	b8 00 00 00 00       	mov    $0x0,%eax
  8029e8:	5d                   	pop    %ebp
  8029e9:	c3                   	ret    

008029ea <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  8029ea:	55                   	push   %ebp
  8029eb:	89 e5                	mov    %esp,%ebp
  8029ed:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<cons>");
  8029f0:	c7 44 24 04 4b 37 80 	movl   $0x80374b,0x4(%esp)
  8029f7:	00 
  8029f8:	8b 45 0c             	mov    0xc(%ebp),%eax
  8029fb:	89 04 24             	mov    %eax,(%esp)
  8029fe:	e8 17 e1 ff ff       	call   800b1a <strcpy>
	return 0;
}
  802a03:	b8 00 00 00 00       	mov    $0x0,%eax
  802a08:	c9                   	leave  
  802a09:	c3                   	ret    

00802a0a <devcons_write>:
	return 1;
}

static ssize_t
devcons_write(struct Fd *fd, const void *vbuf, size_t n)
{
  802a0a:	55                   	push   %ebp
  802a0b:	89 e5                	mov    %esp,%ebp
  802a0d:	57                   	push   %edi
  802a0e:	56                   	push   %esi
  802a0f:	53                   	push   %ebx
  802a10:	81 ec 9c 00 00 00    	sub    $0x9c,%esp
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  802a16:	b8 00 00 00 00       	mov    $0x0,%eax
  802a1b:	be 00 00 00 00       	mov    $0x0,%esi
  802a20:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802a24:	74 41                	je     802a67 <devcons_write+0x5d>
		m = n - tot;
		if (m > sizeof(buf) - 1)
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  802a26:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
		m = n - tot;
  802a2c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  802a2f:	29 c3                	sub    %eax,%ebx
		if (m > sizeof(buf) - 1)
  802a31:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  802a37:	ba 7f 00 00 00       	mov    $0x7f,%edx
  802a3c:	0f 43 da             	cmovae %edx,%ebx
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  802a3f:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802a43:	03 45 0c             	add    0xc(%ebp),%eax
  802a46:	89 44 24 04          	mov    %eax,0x4(%esp)
  802a4a:	89 3c 24             	mov    %edi,(%esp)
  802a4d:	e8 83 e2 ff ff       	call   800cd5 <memmove>
		sys_cputs(buf, m);
  802a52:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802a56:	89 3c 24             	mov    %edi,(%esp)
  802a59:	e8 b2 e4 ff ff       	call   800f10 <sys_cputs>
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  802a5e:	01 de                	add    %ebx,%esi
  802a60:	89 f0                	mov    %esi,%eax
  802a62:	3b 75 10             	cmp    0x10(%ebp),%esi
  802a65:	72 c5                	jb     802a2c <devcons_write+0x22>
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
		sys_cputs(buf, m);
	}
	return tot;
}
  802a67:	89 f0                	mov    %esi,%eax
  802a69:	81 c4 9c 00 00 00    	add    $0x9c,%esp
  802a6f:	5b                   	pop    %ebx
  802a70:	5e                   	pop    %esi
  802a71:	5f                   	pop    %edi
  802a72:	5d                   	pop    %ebp
  802a73:	c3                   	ret    

00802a74 <cputchar>:
#include <inc/string.h>
#include <inc/lib.h>

void
cputchar(int ch)
{
  802a74:	55                   	push   %ebp
  802a75:	89 e5                	mov    %esp,%ebp
  802a77:	83 ec 28             	sub    $0x28,%esp
	char c = ch;
  802a7a:	8b 45 08             	mov    0x8(%ebp),%eax
  802a7d:	88 45 f7             	mov    %al,-0x9(%ebp)

	// Unlike standard Unix's putchar,
	// the cputchar function _always_ outputs to the system console.
	sys_cputs(&c, 1);
  802a80:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  802a87:	00 
  802a88:	8d 45 f7             	lea    -0x9(%ebp),%eax
  802a8b:	89 04 24             	mov    %eax,(%esp)
  802a8e:	e8 7d e4 ff ff       	call   800f10 <sys_cputs>
}
  802a93:	c9                   	leave  
  802a94:	c3                   	ret    

00802a95 <devcons_read>:
	return fd2num(fd);
}

static ssize_t
devcons_read(struct Fd *fd, void *vbuf, size_t n)
{
  802a95:	55                   	push   %ebp
  802a96:	89 e5                	mov    %esp,%ebp
  802a98:	83 ec 08             	sub    $0x8,%esp
	int c;

	if (n == 0)
  802a9b:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802a9f:	75 07                	jne    802aa8 <devcons_read+0x13>
  802aa1:	eb 2d                	jmp    802ad0 <devcons_read+0x3b>
		return 0;
	while ((c = sys_cgetc()) == 0)
		sys_yield();
  802aa3:	e8 2d e8 ff ff       	call   8012d5 <sys_yield>
{
	int c;

	if (n == 0)
		return 0;
	while ((c = sys_cgetc()) == 0)
  802aa8:	90                   	nop
  802aa9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  802ab0:	e8 27 e4 ff ff       	call   800edc <sys_cgetc>
  802ab5:	85 c0                	test   %eax,%eax
  802ab7:	74 ea                	je     802aa3 <devcons_read+0xe>
  802ab9:	89 c2                	mov    %eax,%edx
		sys_yield();
	if (c < 0)
  802abb:	85 c0                	test   %eax,%eax
  802abd:	78 16                	js     802ad5 <devcons_read+0x40>
		return c;
	if (c == 0x04)	// ctl-d is eof
  802abf:	83 f8 04             	cmp    $0x4,%eax
  802ac2:	74 0c                	je     802ad0 <devcons_read+0x3b>
		return 0;
	*(char*)vbuf = c;
  802ac4:	8b 45 0c             	mov    0xc(%ebp),%eax
  802ac7:	88 10                	mov    %dl,(%eax)
  802ac9:	b8 01 00 00 00       	mov    $0x1,%eax
	return 1;
  802ace:	eb 05                	jmp    802ad5 <devcons_read+0x40>
  802ad0:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802ad5:	c9                   	leave  
  802ad6:	c3                   	ret    

00802ad7 <opencons>:
	return fd->fd_dev_id == devcons.dev_id;
}

int
opencons(void)
{
  802ad7:	55                   	push   %ebp
  802ad8:	89 e5                	mov    %esp,%ebp
  802ada:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd* fd;

	if ((r = fd_alloc(&fd)) < 0)
  802add:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802ae0:	89 04 24             	mov    %eax,(%esp)
  802ae3:	e8 e3 ec ff ff       	call   8017cb <fd_alloc>
  802ae8:	85 c0                	test   %eax,%eax
  802aea:	78 3f                	js     802b2b <opencons+0x54>
		return r;
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  802aec:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802af3:	00 
  802af4:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802af7:	89 44 24 04          	mov    %eax,0x4(%esp)
  802afb:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802b02:	e8 6f e7 ff ff       	call   801276 <sys_page_alloc>
  802b07:	85 c0                	test   %eax,%eax
  802b09:	78 20                	js     802b2b <opencons+0x54>
		return r;
	fd->fd_dev_id = devcons.dev_id;
  802b0b:	8b 15 5c 70 80 00    	mov    0x80705c,%edx
  802b11:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802b14:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  802b16:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802b19:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  802b20:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802b23:	89 04 24             	mov    %eax,(%esp)
  802b26:	e8 75 ec ff ff       	call   8017a0 <fd2num>
}
  802b2b:	c9                   	leave  
  802b2c:	c3                   	ret    

00802b2d <iscons>:
	.dev_stat =	devcons_stat
};

int
iscons(int fdnum)
{
  802b2d:	55                   	push   %ebp
  802b2e:	89 e5                	mov    %esp,%ebp
  802b30:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  802b33:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802b36:	89 44 24 04          	mov    %eax,0x4(%esp)
  802b3a:	8b 45 08             	mov    0x8(%ebp),%eax
  802b3d:	89 04 24             	mov    %eax,(%esp)
  802b40:	e8 f8 ec ff ff       	call   80183d <fd_lookup>
  802b45:	85 c0                	test   %eax,%eax
  802b47:	78 11                	js     802b5a <iscons+0x2d>
		return r;
	return fd->fd_dev_id == devcons.dev_id;
  802b49:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802b4c:	8b 00                	mov    (%eax),%eax
  802b4e:	3b 05 5c 70 80 00    	cmp    0x80705c,%eax
  802b54:	0f 94 c0             	sete   %al
  802b57:	0f b6 c0             	movzbl %al,%eax
}
  802b5a:	c9                   	leave  
  802b5b:	c3                   	ret    

00802b5c <getchar>:
	sys_cputs(&c, 1);
}

int
getchar(void)
{
  802b5c:	55                   	push   %ebp
  802b5d:	89 e5                	mov    %esp,%ebp
  802b5f:	83 ec 28             	sub    $0x28,%esp
	int r;

	// JOS does, however, support standard _input_ redirection,
	// allowing the user to redirect script files to the shell and such.
	// getchar() reads a character from file descriptor 0.
	r = read(0, &c, 1);
  802b62:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  802b69:	00 
  802b6a:	8d 45 f7             	lea    -0x9(%ebp),%eax
  802b6d:	89 44 24 04          	mov    %eax,0x4(%esp)
  802b71:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802b78:	e8 26 ef ff ff       	call   801aa3 <read>
	if (r < 0)
  802b7d:	85 c0                	test   %eax,%eax
  802b7f:	78 0f                	js     802b90 <getchar+0x34>
		return r;
	if (r < 1)
  802b81:	85 c0                	test   %eax,%eax
  802b83:	7f 07                	jg     802b8c <getchar+0x30>
  802b85:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  802b8a:	eb 04                	jmp    802b90 <getchar+0x34>
		return -E_EOF;
	return c;
  802b8c:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  802b90:	c9                   	leave  
  802b91:	c3                   	ret    
	...

00802b94 <set_pgfault_handler>:
// at UXSTACKTOP), and tell the kernel to call the assembly-language
// _pgfault_upcall routine when a page fault occurs.
//
void
set_pgfault_handler(void (*handler)(struct UTrapframe *utf))
{
  802b94:	55                   	push   %ebp
  802b95:	89 e5                	mov    %esp,%ebp
  802b97:	83 ec 18             	sub    $0x18,%esp
	int r;

	if (_pgfault_handler == NULL) {
  802b9a:	83 3d 80 70 80 00 00 	cmpl   $0x0,0x807080
  802ba1:	75 55                	jne    802bf8 <set_pgfault_handler+0x64>
		// First time through!
		// LAB 4: Your code here.
        if (sys_page_alloc(sys_getenvid(), (void *)(UXSTACKTOP-PGSIZE), PTE_P|PTE_U|PTE_W))
  802ba3:	e8 61 e7 ff ff       	call   801309 <sys_getenvid>
  802ba8:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802baf:	00 
  802bb0:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  802bb7:	ee 
  802bb8:	89 04 24             	mov    %eax,(%esp)
  802bbb:	e8 b6 e6 ff ff       	call   801276 <sys_page_alloc>
  802bc0:	85 c0                	test   %eax,%eax
  802bc2:	74 1c                	je     802be0 <set_pgfault_handler+0x4c>
		    panic("set_pgfault_handler not implemented");
  802bc4:	c7 44 24 08 58 37 80 	movl   $0x803758,0x8(%esp)
  802bcb:	00 
  802bcc:	c7 44 24 04 21 00 00 	movl   $0x21,0x4(%esp)
  802bd3:	00 
  802bd4:	c7 04 24 7c 37 80 00 	movl   $0x80377c,(%esp)
  802bdb:	e8 a4 d7 ff ff       	call   800384 <_panic>
        sys_env_set_pgfault_upcall(env->env_id, _pgfault_upcall);
  802be0:	a1 78 70 80 00       	mov    0x807078,%eax
  802be5:	8b 40 4c             	mov    0x4c(%eax),%eax
  802be8:	c7 44 24 04 04 2c 80 	movl   $0x802c04,0x4(%esp)
  802bef:	00 
  802bf0:	89 04 24             	mov    %eax,(%esp)
  802bf3:	e8 a8 e4 ff ff       	call   8010a0 <sys_env_set_pgfault_upcall>
	}

	// Save handler pointer for assembly to call.
	_pgfault_handler = handler;
  802bf8:	8b 45 08             	mov    0x8(%ebp),%eax
  802bfb:	a3 80 70 80 00       	mov    %eax,0x807080
}
  802c00:	c9                   	leave  
  802c01:	c3                   	ret    
	...

00802c04 <_pgfault_upcall>:

.text
.globl _pgfault_upcall
_pgfault_upcall:
	// Call the C page fault handler.
	pushl %esp			// function argument: pointer to UTF
  802c04:	54                   	push   %esp
	movl _pgfault_handler, %eax
  802c05:	a1 80 70 80 00       	mov    0x807080,%eax
	call *%eax
  802c0a:	ff d0                	call   *%eax
	addl $4, %esp			// pop function argument
  802c0c:	83 c4 04             	add    $0x4,%esp
	// may find that you have to rearrange your code in non-obvious
	// ways as registers become unavailable as scratch space.
	//
	// LAB 4: Your code here.

    subl $4, 48(%esp)
  802c0f:	83 6c 24 30 04       	subl   $0x4,0x30(%esp)
    movl 48(%esp), %eax
  802c14:	8b 44 24 30          	mov    0x30(%esp),%eax
    movl 40(%esp), %ebx
  802c18:	8b 5c 24 28          	mov    0x28(%esp),%ebx
    movl %ebx, (%eax)
  802c1c:	89 18                	mov    %ebx,(%eax)
    
	// Restore the trap-time registers.  After you do this, you
	// can no longer modify any general-purpose registers.
	// LAB 4: Your code here.
    addl $8, %esp
  802c1e:	83 c4 08             	add    $0x8,%esp
    popal
  802c21:	61                   	popa   
   
	// Restore eflags from the stack.  After you do this, you can
	// no longer use arithmetic operations or anything else that
	// modifies eflags.
	// LAB 4: Your code here.
    pushl 4(%esp)
  802c22:	ff 74 24 04          	pushl  0x4(%esp)
    popf
  802c26:	9d                   	popf   

	// Switch back to the adjusted trap-time stack.
	// LAB 4: Your code here.
    movl 8(%esp), %esp
  802c27:	8b 64 24 08          	mov    0x8(%esp),%esp

	// Return to re-execute the instruction that faulted.
	// LAB 4: Your code here.
    ret
  802c2b:	c3                   	ret    
  802c2c:	00 00                	add    %al,(%eax)
	...

00802c30 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  802c30:	55                   	push   %ebp
  802c31:	89 e5                	mov    %esp,%ebp
  802c33:	57                   	push   %edi
  802c34:	56                   	push   %esi
  802c35:	53                   	push   %ebx
  802c36:	83 ec 2c             	sub    $0x2c,%esp
  802c39:	8b 75 08             	mov    0x8(%ebp),%esi
  802c3c:	8b 7d 0c             	mov    0xc(%ebp),%edi
  802c3f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
  802c42:	85 db                	test   %ebx,%ebx
  802c44:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  802c49:	0f 45 c3             	cmovne %ebx,%eax
  802c4c:	8b 55 14             	mov    0x14(%ebp),%edx
  802c4f:	89 54 24 0c          	mov    %edx,0xc(%esp)
  802c53:	89 44 24 08          	mov    %eax,0x8(%esp)
  802c57:	89 7c 24 04          	mov    %edi,0x4(%esp)
  802c5b:	89 34 24             	mov    %esi,(%esp)
  802c5e:	e8 dd e3 ff ff       	call   801040 <sys_ipc_try_send>
  802c63:	83 f8 f9             	cmp    $0xfffffff9,%eax
  802c66:	75 0a                	jne    802c72 <ipc_send+0x42>
      sys_yield();
  802c68:	e8 68 e6 ff ff       	call   8012d5 <sys_yield>
    else if (r < 0)
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
    else
      return;
  }
  802c6d:	8d 76 00             	lea    0x0(%esi),%esi
  802c70:	eb d0                	jmp    802c42 <ipc_send+0x12>
{
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
      sys_yield();
    else if (r < 0)
  802c72:	85 c0                	test   %eax,%eax
  802c74:	79 24                	jns    802c9a <ipc_send+0x6a>
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
  802c76:	89 44 24 10          	mov    %eax,0x10(%esp)
  802c7a:	89 74 24 0c          	mov    %esi,0xc(%esp)
  802c7e:	c7 44 24 08 8c 37 80 	movl   $0x80378c,0x8(%esp)
  802c85:	00 
  802c86:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  802c8d:	00 
  802c8e:	c7 04 24 b0 37 80 00 	movl   $0x8037b0,(%esp)
  802c95:	e8 ea d6 ff ff       	call   800384 <_panic>
    else
      return;
  }
}
  802c9a:	83 c4 2c             	add    $0x2c,%esp
  802c9d:	5b                   	pop    %ebx
  802c9e:	5e                   	pop    %esi
  802c9f:	5f                   	pop    %edi
  802ca0:	5d                   	pop    %ebp
  802ca1:	c3                   	ret    

00802ca2 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  802ca2:	55                   	push   %ebp
  802ca3:	89 e5                	mov    %esp,%ebp
  802ca5:	56                   	push   %esi
  802ca6:	53                   	push   %ebx
  802ca7:	83 ec 10             	sub    $0x10,%esp
  802caa:	8b 5d 08             	mov    0x8(%ebp),%ebx
  802cad:	8b 45 0c             	mov    0xc(%ebp),%eax
  802cb0:	8b 75 10             	mov    0x10(%ebp),%esi
  int r;
  if ((r=sys_ipc_recv((pg==NULL?(void *)UTOP:pg)))<0)
  802cb3:	85 c0                	test   %eax,%eax
  802cb5:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  802cba:	0f 44 c2             	cmove  %edx,%eax
  802cbd:	89 04 24             	mov    %eax,(%esp)
  802cc0:	e8 1e e3 ff ff       	call   800fe3 <sys_ipc_recv>
  802cc5:	85 c0                	test   %eax,%eax
  802cc7:	78 24                	js     802ced <ipc_recv+0x4b>
    return r;

  if (from_env_store)
  802cc9:	85 db                	test   %ebx,%ebx
  802ccb:	74 0a                	je     802cd7 <ipc_recv+0x35>
    *from_env_store = env->env_ipc_from;
  802ccd:	a1 78 70 80 00       	mov    0x807078,%eax
  802cd2:	8b 40 74             	mov    0x74(%eax),%eax
  802cd5:	89 03                	mov    %eax,(%ebx)

  if (perm_store)
  802cd7:	85 f6                	test   %esi,%esi
  802cd9:	74 0a                	je     802ce5 <ipc_recv+0x43>
    *perm_store     = env->env_ipc_perm;
  802cdb:	a1 78 70 80 00       	mov    0x807078,%eax
  802ce0:	8b 40 78             	mov    0x78(%eax),%eax
  802ce3:	89 06                	mov    %eax,(%esi)

  return env->env_ipc_value;
  802ce5:	a1 78 70 80 00       	mov    0x807078,%eax
  802cea:	8b 40 70             	mov    0x70(%eax),%eax
}
  802ced:	83 c4 10             	add    $0x10,%esp
  802cf0:	5b                   	pop    %ebx
  802cf1:	5e                   	pop    %esi
  802cf2:	5d                   	pop    %ebp
  802cf3:	c3                   	ret    

00802cf4 <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  802cf4:	55                   	push   %ebp
  802cf5:	89 e5                	mov    %esp,%ebp
	pte_t pte;

	if (!(vpd[PDX(v)] & PTE_P))
  802cf7:	8b 45 08             	mov    0x8(%ebp),%eax
  802cfa:	89 c2                	mov    %eax,%edx
  802cfc:	c1 ea 16             	shr    $0x16,%edx
  802cff:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  802d06:	f6 c2 01             	test   $0x1,%dl
  802d09:	74 26                	je     802d31 <pageref+0x3d>
		return 0;
	pte = vpt[VPN(v)];
  802d0b:	c1 e8 0c             	shr    $0xc,%eax
  802d0e:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  802d15:	a8 01                	test   $0x1,%al
  802d17:	74 18                	je     802d31 <pageref+0x3d>
		return 0;
	return pages[PPN(pte)].pp_ref;
  802d19:	c1 e8 0c             	shr    $0xc,%eax
  802d1c:	8d 14 40             	lea    (%eax,%eax,2),%edx
  802d1f:	c1 e2 02             	shl    $0x2,%edx
  802d22:	b8 00 00 00 ef       	mov    $0xef000000,%eax
  802d27:	0f b7 44 02 08       	movzwl 0x8(%edx,%eax,1),%eax
  802d2c:	0f b7 c0             	movzwl %ax,%eax
  802d2f:	eb 05                	jmp    802d36 <pageref+0x42>
  802d31:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802d36:	5d                   	pop    %ebp
  802d37:	c3                   	ret    
	...

00802d40 <__udivdi3>:
  802d40:	55                   	push   %ebp
  802d41:	89 e5                	mov    %esp,%ebp
  802d43:	57                   	push   %edi
  802d44:	56                   	push   %esi
  802d45:	83 ec 10             	sub    $0x10,%esp
  802d48:	8b 45 14             	mov    0x14(%ebp),%eax
  802d4b:	8b 55 08             	mov    0x8(%ebp),%edx
  802d4e:	8b 75 10             	mov    0x10(%ebp),%esi
  802d51:	8b 7d 0c             	mov    0xc(%ebp),%edi
  802d54:	85 c0                	test   %eax,%eax
  802d56:	89 55 f0             	mov    %edx,-0x10(%ebp)
  802d59:	75 35                	jne    802d90 <__udivdi3+0x50>
  802d5b:	39 fe                	cmp    %edi,%esi
  802d5d:	77 61                	ja     802dc0 <__udivdi3+0x80>
  802d5f:	85 f6                	test   %esi,%esi
  802d61:	75 0b                	jne    802d6e <__udivdi3+0x2e>
  802d63:	b8 01 00 00 00       	mov    $0x1,%eax
  802d68:	31 d2                	xor    %edx,%edx
  802d6a:	f7 f6                	div    %esi
  802d6c:	89 c6                	mov    %eax,%esi
  802d6e:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  802d71:	31 d2                	xor    %edx,%edx
  802d73:	89 f8                	mov    %edi,%eax
  802d75:	f7 f6                	div    %esi
  802d77:	89 c7                	mov    %eax,%edi
  802d79:	89 c8                	mov    %ecx,%eax
  802d7b:	f7 f6                	div    %esi
  802d7d:	89 c1                	mov    %eax,%ecx
  802d7f:	89 fa                	mov    %edi,%edx
  802d81:	89 c8                	mov    %ecx,%eax
  802d83:	83 c4 10             	add    $0x10,%esp
  802d86:	5e                   	pop    %esi
  802d87:	5f                   	pop    %edi
  802d88:	5d                   	pop    %ebp
  802d89:	c3                   	ret    
  802d8a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  802d90:	39 f8                	cmp    %edi,%eax
  802d92:	77 1c                	ja     802db0 <__udivdi3+0x70>
  802d94:	0f bd d0             	bsr    %eax,%edx
  802d97:	83 f2 1f             	xor    $0x1f,%edx
  802d9a:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802d9d:	75 39                	jne    802dd8 <__udivdi3+0x98>
  802d9f:	3b 75 f0             	cmp    -0x10(%ebp),%esi
  802da2:	0f 86 a0 00 00 00    	jbe    802e48 <__udivdi3+0x108>
  802da8:	39 f8                	cmp    %edi,%eax
  802daa:	0f 82 98 00 00 00    	jb     802e48 <__udivdi3+0x108>
  802db0:	31 ff                	xor    %edi,%edi
  802db2:	31 c9                	xor    %ecx,%ecx
  802db4:	89 c8                	mov    %ecx,%eax
  802db6:	89 fa                	mov    %edi,%edx
  802db8:	83 c4 10             	add    $0x10,%esp
  802dbb:	5e                   	pop    %esi
  802dbc:	5f                   	pop    %edi
  802dbd:	5d                   	pop    %ebp
  802dbe:	c3                   	ret    
  802dbf:	90                   	nop
  802dc0:	89 d1                	mov    %edx,%ecx
  802dc2:	89 fa                	mov    %edi,%edx
  802dc4:	89 c8                	mov    %ecx,%eax
  802dc6:	31 ff                	xor    %edi,%edi
  802dc8:	f7 f6                	div    %esi
  802dca:	89 c1                	mov    %eax,%ecx
  802dcc:	89 fa                	mov    %edi,%edx
  802dce:	89 c8                	mov    %ecx,%eax
  802dd0:	83 c4 10             	add    $0x10,%esp
  802dd3:	5e                   	pop    %esi
  802dd4:	5f                   	pop    %edi
  802dd5:	5d                   	pop    %ebp
  802dd6:	c3                   	ret    
  802dd7:	90                   	nop
  802dd8:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802ddc:	89 f2                	mov    %esi,%edx
  802dde:	d3 e0                	shl    %cl,%eax
  802de0:	89 45 ec             	mov    %eax,-0x14(%ebp)
  802de3:	b8 20 00 00 00       	mov    $0x20,%eax
  802de8:	2b 45 f4             	sub    -0xc(%ebp),%eax
  802deb:	89 c1                	mov    %eax,%ecx
  802ded:	d3 ea                	shr    %cl,%edx
  802def:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802df3:	0b 55 ec             	or     -0x14(%ebp),%edx
  802df6:	d3 e6                	shl    %cl,%esi
  802df8:	89 c1                	mov    %eax,%ecx
  802dfa:	89 75 e8             	mov    %esi,-0x18(%ebp)
  802dfd:	89 fe                	mov    %edi,%esi
  802dff:	d3 ee                	shr    %cl,%esi
  802e01:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802e05:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802e08:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802e0b:	d3 e7                	shl    %cl,%edi
  802e0d:	89 c1                	mov    %eax,%ecx
  802e0f:	d3 ea                	shr    %cl,%edx
  802e11:	09 d7                	or     %edx,%edi
  802e13:	89 f2                	mov    %esi,%edx
  802e15:	89 f8                	mov    %edi,%eax
  802e17:	f7 75 ec             	divl   -0x14(%ebp)
  802e1a:	89 d6                	mov    %edx,%esi
  802e1c:	89 c7                	mov    %eax,%edi
  802e1e:	f7 65 e8             	mull   -0x18(%ebp)
  802e21:	39 d6                	cmp    %edx,%esi
  802e23:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802e26:	72 30                	jb     802e58 <__udivdi3+0x118>
  802e28:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802e2b:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802e2f:	d3 e2                	shl    %cl,%edx
  802e31:	39 c2                	cmp    %eax,%edx
  802e33:	73 05                	jae    802e3a <__udivdi3+0xfa>
  802e35:	3b 75 ec             	cmp    -0x14(%ebp),%esi
  802e38:	74 1e                	je     802e58 <__udivdi3+0x118>
  802e3a:	89 f9                	mov    %edi,%ecx
  802e3c:	31 ff                	xor    %edi,%edi
  802e3e:	e9 71 ff ff ff       	jmp    802db4 <__udivdi3+0x74>
  802e43:	90                   	nop
  802e44:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802e48:	31 ff                	xor    %edi,%edi
  802e4a:	b9 01 00 00 00       	mov    $0x1,%ecx
  802e4f:	e9 60 ff ff ff       	jmp    802db4 <__udivdi3+0x74>
  802e54:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802e58:	8d 4f ff             	lea    -0x1(%edi),%ecx
  802e5b:	31 ff                	xor    %edi,%edi
  802e5d:	89 c8                	mov    %ecx,%eax
  802e5f:	89 fa                	mov    %edi,%edx
  802e61:	83 c4 10             	add    $0x10,%esp
  802e64:	5e                   	pop    %esi
  802e65:	5f                   	pop    %edi
  802e66:	5d                   	pop    %ebp
  802e67:	c3                   	ret    
	...

00802e70 <__umoddi3>:
  802e70:	55                   	push   %ebp
  802e71:	89 e5                	mov    %esp,%ebp
  802e73:	57                   	push   %edi
  802e74:	56                   	push   %esi
  802e75:	83 ec 20             	sub    $0x20,%esp
  802e78:	8b 55 14             	mov    0x14(%ebp),%edx
  802e7b:	8b 4d 08             	mov    0x8(%ebp),%ecx
  802e7e:	8b 7d 10             	mov    0x10(%ebp),%edi
  802e81:	8b 75 0c             	mov    0xc(%ebp),%esi
  802e84:	85 d2                	test   %edx,%edx
  802e86:	89 c8                	mov    %ecx,%eax
  802e88:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  802e8b:	75 13                	jne    802ea0 <__umoddi3+0x30>
  802e8d:	39 f7                	cmp    %esi,%edi
  802e8f:	76 3f                	jbe    802ed0 <__umoddi3+0x60>
  802e91:	89 f2                	mov    %esi,%edx
  802e93:	f7 f7                	div    %edi
  802e95:	89 d0                	mov    %edx,%eax
  802e97:	31 d2                	xor    %edx,%edx
  802e99:	83 c4 20             	add    $0x20,%esp
  802e9c:	5e                   	pop    %esi
  802e9d:	5f                   	pop    %edi
  802e9e:	5d                   	pop    %ebp
  802e9f:	c3                   	ret    
  802ea0:	39 f2                	cmp    %esi,%edx
  802ea2:	77 4c                	ja     802ef0 <__umoddi3+0x80>
  802ea4:	0f bd ca             	bsr    %edx,%ecx
  802ea7:	83 f1 1f             	xor    $0x1f,%ecx
  802eaa:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  802ead:	75 51                	jne    802f00 <__umoddi3+0x90>
  802eaf:	3b 7d f4             	cmp    -0xc(%ebp),%edi
  802eb2:	0f 87 e0 00 00 00    	ja     802f98 <__umoddi3+0x128>
  802eb8:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802ebb:	29 f8                	sub    %edi,%eax
  802ebd:	19 d6                	sbb    %edx,%esi
  802ebf:	89 45 f4             	mov    %eax,-0xc(%ebp)
  802ec2:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802ec5:	89 f2                	mov    %esi,%edx
  802ec7:	83 c4 20             	add    $0x20,%esp
  802eca:	5e                   	pop    %esi
  802ecb:	5f                   	pop    %edi
  802ecc:	5d                   	pop    %ebp
  802ecd:	c3                   	ret    
  802ece:	66 90                	xchg   %ax,%ax
  802ed0:	85 ff                	test   %edi,%edi
  802ed2:	75 0b                	jne    802edf <__umoddi3+0x6f>
  802ed4:	b8 01 00 00 00       	mov    $0x1,%eax
  802ed9:	31 d2                	xor    %edx,%edx
  802edb:	f7 f7                	div    %edi
  802edd:	89 c7                	mov    %eax,%edi
  802edf:	89 f0                	mov    %esi,%eax
  802ee1:	31 d2                	xor    %edx,%edx
  802ee3:	f7 f7                	div    %edi
  802ee5:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802ee8:	f7 f7                	div    %edi
  802eea:	eb a9                	jmp    802e95 <__umoddi3+0x25>
  802eec:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802ef0:	89 c8                	mov    %ecx,%eax
  802ef2:	89 f2                	mov    %esi,%edx
  802ef4:	83 c4 20             	add    $0x20,%esp
  802ef7:	5e                   	pop    %esi
  802ef8:	5f                   	pop    %edi
  802ef9:	5d                   	pop    %ebp
  802efa:	c3                   	ret    
  802efb:	90                   	nop
  802efc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802f00:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802f04:	d3 e2                	shl    %cl,%edx
  802f06:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802f09:	ba 20 00 00 00       	mov    $0x20,%edx
  802f0e:	2b 55 f0             	sub    -0x10(%ebp),%edx
  802f11:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802f14:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802f18:	89 fa                	mov    %edi,%edx
  802f1a:	d3 ea                	shr    %cl,%edx
  802f1c:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802f20:	0b 55 f4             	or     -0xc(%ebp),%edx
  802f23:	d3 e7                	shl    %cl,%edi
  802f25:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802f29:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802f2c:	89 f2                	mov    %esi,%edx
  802f2e:	89 7d e8             	mov    %edi,-0x18(%ebp)
  802f31:	89 c7                	mov    %eax,%edi
  802f33:	d3 ea                	shr    %cl,%edx
  802f35:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802f39:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  802f3c:	89 c2                	mov    %eax,%edx
  802f3e:	d3 e6                	shl    %cl,%esi
  802f40:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802f44:	d3 ea                	shr    %cl,%edx
  802f46:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802f4a:	09 d6                	or     %edx,%esi
  802f4c:	89 f0                	mov    %esi,%eax
  802f4e:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  802f51:	d3 e7                	shl    %cl,%edi
  802f53:	89 f2                	mov    %esi,%edx
  802f55:	f7 75 f4             	divl   -0xc(%ebp)
  802f58:	89 d6                	mov    %edx,%esi
  802f5a:	f7 65 e8             	mull   -0x18(%ebp)
  802f5d:	39 d6                	cmp    %edx,%esi
  802f5f:	72 2b                	jb     802f8c <__umoddi3+0x11c>
  802f61:	39 c7                	cmp    %eax,%edi
  802f63:	72 23                	jb     802f88 <__umoddi3+0x118>
  802f65:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802f69:	29 c7                	sub    %eax,%edi
  802f6b:	19 d6                	sbb    %edx,%esi
  802f6d:	89 f0                	mov    %esi,%eax
  802f6f:	89 f2                	mov    %esi,%edx
  802f71:	d3 ef                	shr    %cl,%edi
  802f73:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802f77:	d3 e0                	shl    %cl,%eax
  802f79:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802f7d:	09 f8                	or     %edi,%eax
  802f7f:	d3 ea                	shr    %cl,%edx
  802f81:	83 c4 20             	add    $0x20,%esp
  802f84:	5e                   	pop    %esi
  802f85:	5f                   	pop    %edi
  802f86:	5d                   	pop    %ebp
  802f87:	c3                   	ret    
  802f88:	39 d6                	cmp    %edx,%esi
  802f8a:	75 d9                	jne    802f65 <__umoddi3+0xf5>
  802f8c:	2b 45 e8             	sub    -0x18(%ebp),%eax
  802f8f:	1b 55 f4             	sbb    -0xc(%ebp),%edx
  802f92:	eb d1                	jmp    802f65 <__umoddi3+0xf5>
  802f94:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802f98:	39 f2                	cmp    %esi,%edx
  802f9a:	0f 82 18 ff ff ff    	jb     802eb8 <__umoddi3+0x48>
  802fa0:	e9 1d ff ff ff       	jmp    802ec2 <__umoddi3+0x52>
